summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2004-01-09 15:00:41 +0000
committerMartin Odersky <odersky@gmail.com>2004-01-09 15:00:41 +0000
commit2f88fe7918a98e0e076fc3d44e9b8ca646c64c1f (patch)
tree629412ad71ebcaa3a27e50f9c82bf4be62af7ccc /doc
parent253a192ede3e994d6c832c124c7c02fb551d1006 (diff)
downloadscala-2f88fe7918a98e0e076fc3d44e9b8ca646c64c1f.tar.gz
scala-2f88fe7918a98e0e076fc3d44e9b8ca646c64c1f.tar.bz2
scala-2f88fe7918a98e0e076fc3d44e9b8ca646c64c1f.zip
*** empty log message ***
Diffstat (limited to 'doc')
-rw-r--r--doc/reference/ScalaByExample.tex22
1 files changed, 10 insertions, 12 deletions
diff --git a/doc/reference/ScalaByExample.tex b/doc/reference/ScalaByExample.tex
index 850cc53eec..90c45145a3 100644
--- a/doc/reference/ScalaByExample.tex
+++ b/doc/reference/ScalaByExample.tex
@@ -6387,13 +6387,6 @@ lists:
class LinkedList[a] {
var elem: a = _;
var next: LinkedList[a] = null;
- def insert(elem: a): LinkedList[a] = {
- val nx = new LinkedList[a];
- nx.elem = a;
- nx.next = next;
- next = nx;
- next
- }
}
\end{lstlisting}
To facilitate insertion and deletion of elements into linked lists,
@@ -6409,8 +6402,12 @@ incrementing the \code{nreaders} field and waiting to be notified.
package scala.concurrent;
class Channel[a] with Monitor {
+ class LinkedList[a] {
+ var elem: a = _;
+ var next: LinkedList[a] = null;
+ }
private var written = new LinkedList[a];
- private var lastWritten = written;
+ private var lastWritten = new LinkedList[a];
private var nreaders = 0;
def write(x: a) = synchronized {
@@ -6424,8 +6421,9 @@ class Channel[a] with Monitor {
if (written.next == null) {
nreaders = nreaders + 1; wait(); nreaders = nreaders - 1;
}
+ val x = written.elem;
written = written.next;
- written.elem;
+ x
}
}
\end{lstlisting}
@@ -6712,17 +6710,17 @@ forwards all communication calls to an internal mailbox.
\begin{lstlisting}
abstract class Actor extends Thread {
- type Message = Any;
+ type Message = AnyRef;
private val mb = new MailBox;
def send(msg: Message): unit =
mb.send(msg);
- protected def receive[a](f: PartialFunction[Message, a]): a =
+ def receive[a](f: PartialFunction[Message, a]): a =
mb.receive(f);
- protected def receiveWithin[a](msec: long)(f: PartialFunction[Message, a]): a =
+ def receiveWithin[a](msec: long)(f: PartialFunction[Message, a]): a =
mb.receiveWithin(msec)(f);
}
\end{lstlisting}