Aladdin - Scala Bugtracking
[#896] project: documentation priority: low category: bug
submitter assigned to status date submitted
Nikolay Martin fixed 2007-01-16 16:36:17.0
subject [contrib #272] Invalid code in ScalaByExample
code
/* From ScalaByExample.pdf dated November 23, 2006
   distributed with Scala compiler 2.3.0 */


// page 9

Array.concat(
sort(xs filter (pivot >))  // needs a trailing comma
xs filter (pivot ==),
sort(xs filter (pivot <)))
}



// page 14

// Actor is used without an import. Solution:-
// import scala.actors.Actor


// page 15

var maxBidder: Actor = _
// error: local variables must be initialized
// Alternatives include
// var maxBidder: Actor = null // rest of function not affected
// var maxBidder: Option[Actor] = None // uses of maxBidder need updating


receiveWithin ((closing.getTime() - new Date().getTime())) {
// error: not found: value receiveWithin
// Solution ???



// page 23

/*
Every definition in a block must be followed by a semicolon, which separates this
definition from subsequent definitions or the result expression. However, a semicolon
is inserted implicitly if the definition ends in a right brace and is followed by
a new line. Therefore, the following are all legal:
*/
// No longer accurate: ‘;’ is no longer mandatory if 
// the definition is followed by a new line.

def f(x) = x + 1; /* ‘;’ mandatory */
// error: ':' expected but ')' found.
// def f(x: double) = x + 1



// I haven't tested further
what happened
Compiler errors
what expected Successful compiles. I suspect the examples were written for an older version of the language and haven't been updated.
[back to overview]
Changes of this bug report
Nikolay  edited on  2007-01-16 16:36:47.0
contribution #272
Martin  edited on  2007-01-23 16:29:10.0