Skip to content

Commit

Permalink
Use the new syntax for def parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
mihaylov committed Aug 26, 2005
1 parent bc6f997 commit 7d50bd1
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion doc/reference/ScalaByExample.tex
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ \chapter{Implementing Abstract Types: Search Trees}
which creates a map from strings to integers and then applies it to a
key string:
\begin{lstlisting}
def mapTest(def mapImpl: MapStruct[String, int]): int = {
def mapTest(mapImpl: => MapStruct[String, int]): int = {
val map: mapImpl.Map = mapImpl.empty.extend("ab", 1).extend("bx", 3)
val x = map("ab") // returns 1
}
Expand Down
2 changes: 1 addition & 1 deletion sources/examples/computeserver.scala
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class ComputeServer(n: Int) {
}
}

def future[a](def p: a): () => a = {
def future[a](p: => a): () => a = {
val reply = new SyncVar[a]();
openJobs.write{
new Job {
Expand Down
2 changes: 1 addition & 1 deletion sources/examples/jolib/parallelOr.scala
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ object or extends Join {
r.set(b) })
);
def apply(def b1: boolean, def b2: boolean): boolean = {
def apply(b1: => boolean, b2: => boolean): boolean = {
concurrent.ops.spawn(res1(res1.C(b1)));
concurrent.ops.spawn(res2(res2.C(b2)));
res(res.C())
Expand Down
2 changes: 1 addition & 1 deletion sources/examples/pilib/rwlock.scala
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ object rwlock {
}
}

def await(def cond: boolean): unit = while (false == cond) (Wait)
def await(cond: => boolean): unit = while (false == cond) (Wait)
}

/*
Expand Down
2 changes: 1 addition & 1 deletion sources/examples/pilib/semaphore.scala
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ object semaphore {
def main(args: Array[String]): unit = {
val random = new java.util.Random();
val sem = new Sem2;
def mutex(def p: unit): unit = { sem.get; p; sem.release }
def mutex(p: => unit): unit = { sem.get; p; sem.release }

spawn< {
Thread.sleep(1 + random.nextInt(100));
Expand Down
4 changes: 2 additions & 2 deletions test/benchmark/sources/parsers/parsers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ abstract class Parsers {

/*** p &&& q applies first p, and if that succeeds, then q
*/
def &&& (def q: Parser) = new Parser {
def &&& (q: => Parser) = new Parser {
def apply(in: intype): Result = Parser.this.apply(in) match {
case None => None
case Some(in1) => q(in1)
Expand All @@ -31,7 +31,7 @@ abstract class Parsers {

/*** p ||| q applies first p, and, if that fails, then q.
*/
def ||| (def q: Parser) = new Parser {
def ||| (q: => Parser) = new Parser {
def apply(in: intype): Result = Parser.this.apply(in) match {
case None => q(in)
case s => s
Expand Down

0 comments on commit 7d50bd1

Please sign in to comment.