The Artima Developer Community


Errata for Actors in Scala
Chapter 5: Event-Based Programming
Return to errata index.

Page 56 (PDF page 56):
"Listing 5.1 shows the definition of a method that recursively builds a
chain of actors and returns the first actor" explanation at page 56 may
be misleading with given implementation. 
Returned actor is the last actor created by the buildChain method not the
first
(if we start numbering actors in order they are being created)
Page 57 (PDF page 57):
buildChain function creates size+1 actors with existing implementation

def buildChain(size: Int, next: Actor): Actor = {
...
size > 0) buildChain(size - 1, a)
    else a
..

should be:

def buildChain(size: Int, next: Actor): Actor = {
...
size > 1) buildChain(size - 1, a)
    else a
..
Page 61 (PDF page 61):
"Listing 5.5 shows how to do this by replacing the body of the chain
actors wit a call to waitFor method" 
explanation is not sufficient for the proper usage of multiple message
awaits:

Missing issues:

* First actor should receive n 'Die messages. Sample initialisation for 2
messages

    val lastCreated: Actor = buildChainModified(numActors, null)
    lastCreated ! 'Die
    lastCreated ! 'Die

* Also main should await for n number of consecutive Ack messages, Sample
usage for 2 messages:
   
  receive {
      case 'Ack =>
        receive {
          case 'Ack =>
            val end = System.currentTimeMillis()
            println("MODIFIED VERSION: Took " + (end - start) + " ms for
the creation of " + numActors + " Actors")

        }
    }
Page 67 (PDF page 67):
Listing 5.10 deoes not work properly: 

when loop is constructed with while and receive is used, works as
expected 

however when updated to loopWhile and react, with the given
implementation, you may and most probably get
scala.actors.SuspendActorControl
Page 68 (PDF page 68):
val it = iter.elements line in Listing 5.12 should be  val it =
iter.toIterator
Page 57 (PDF page 75):
Listing 5.1 uses symbols, but these are explained only on page 72 (in
footnote 1 - should be moved to page 57).
Page 65 (PDF page 83):
Listing 5.9 (and several later listings) use the @ syntax in pattern
matching without explaining it.

Page number: Book type: Paperback book PDF eBook
Book version: (Or build date. Found on back of title page.)
Your feedback:
Your name: (optional)
Your email address: (optional) (will not be published)

Copyright © 2024 Artima, Inc. All rights reserved.