Aladdin - Scala Bugtracking
[#894] project: documentation priority: low category: bug
submitter assigned to status date submitted
Nikolay Martin fixed 2007-01-16 16:32:06.0
subject [contrib #281] Invalid code in Changes between Scala 1.0 and 2.0
code
In the document
"Changes between Scala Version 1.0 and 2.0"
some of the examples don't compile with 2.3.1 and likely didn't compile with 2.0 either.


(Optional) Add abstract on page 6:
Change
class Inner {
to
abstract class Inner {


Missing ")" and incorrect argument order on page 12:
The last line of sum should change from
else m.add(xs.head, sum(m)(xs.tail)
to
else m.add(xs.head, sum(xs.tail)(m))


(Optional) int2ordered no longer implements Ordered correctly on page 13:
Perhaps this did work for 2.0 and the language has changed since. In this case,   it may be best to leave the code and example as-is, optionally with a disclaimer that Ordered has changed since 2.0.

The following alternative code compiles with 2.3.1 but there's little point adding it because:
(a) I suspect it doesn't compile with Scala 1.0 and/or 2.0
(b) Predef.intWrapper already provides an implicit conversion from int to Ordered[int]
implicit def int2ordered(x: int): Ordered[int] = new Ordered[int] {
def compare(y: Int): int = 
  if (x < y) -1
  else if (x > y) 1
  else 0
}


Excess "if" on page 14:
The last line of merge should change from
else if ys.head :: merge(xs, ys.tail)
to
else ys.head :: merge(xs, ys.tail)


Excess "if" on page 15:
The last line of expanded merge implementation (continued from page 14) should change from
else if ys.head :: merge(xs, ys.tail)(c)
to
else ys.head :: merge(xs, ys.tail)(c)
what happened
Compiler errors
what expected Successful compiles
[back to overview]
Changes of this bug report
Nikolay  edited on  2007-01-16 16:32:41.0
contribution #281
Martin  edited on  2007-01-23 16:52:13.0