Since version 2.0 of March 2006 the Scala compiler is completely written in Scala itself.
Version | Released | Selected additions/changes from release notes |
---|---|---|
2.10.0-M3 | 2012-04-29 |
|
2.9.2 | 2012-04-14 | no language changes |
2.9.1 | 2011-08-31 | no language changes |
2.9.0.1 | 2011-05-25 | maintainance release |
2.9.0 | 2011-05-12 |
|
2.8.2.final | 2011-09-27 | maintainance release |
2.8.1 | 2010-11-09 |
|
2.8.0 | 2010-07-13 |
|
2.7.7 | 2009-10-28 | maintainance release |
2.7.6 | 2009-09-09 | maintainance release |
2.7.5 | 2009-05-31 | maintainance release |
2.7.2 | 2008-11-10 | maintainance release |
2.7.1 | 2008-04-09 |
|
2.7.0 | 2008-02-07 |
|
2.6.1 | 2007-11-30 |
|
2.6.0 | 2007-07-27 |
|
2.5.1 | 2007-06-13 | maintainance release |
2.5.0 | 2007-05-02 |
|
2.4.0 | 2007-03-21 |
|
2.3.3 | 2007-01-26 | maintainance release |
2.3.2 | 2007-01-23 |
|
2.3.1 | 2006-12-06 | maintainance release |
2.3.0 | 2006-11-23 |
|
2.2.0 | 2006-10-11 |
|
2.1.8 | 2006-08-23 |
|
2.1.7 | 2006-07-19 |
|
2.1.6 | 2006-06-16 |
|
2.1.5 | 2006-05-24 |
|
2.1.4 | 2006-05-01 | maintainance release |
2.1.3 | 2006-04-13 | maintainance release |
2.1.2 | 2006-03-31 | maintainance release |
2.1.1 | 2006-03-29 | maintainance release |
2.1.0 | 2006-03-17 |
|
2.0 | 2006-03-12 |
|
1.4.0.4 | 2006-01-19 | maintainance release |
1.4.0.3 | 2005-11-16 | maintainance release |
1.4.0.2 | 2005-10-15 | maintainance release |
1.4.0.1 | 2005-10-13 | maintainance release |
1.4.0.0 | 2005-06-20 |
|
1.3.0.10 | 2005-03-07 |
|
1.3.0.9 | 2004-11-23 | maintainance release |
1.3.0.7 | 2004-11-16 | maintainance release |
1.3.0.4 | 2004-09-29 | maintainance release |
1.3.0.3 | 2004-09-23 | maintainance release |
1.3.0.2 | 2004-09-16 |
|
1.2.0.1 | 2004-07-27 |
|
1.2.0.0 | 2004-06-09 |
|
1.1.1.3 | 2004-04-15 |
|
1.1.1.0 | 2004-03-23 |
|
1.1.0-b3 | 2004-02-19 | maintainance release |
1.0.0-b4 | 2004-01-12 |
|
1.0.0-b2 | 2003-12-08 |
|
Language features producing a compiler warning (since 2.10.x) [↑]
// File features.scala class WrappedString(s: String) { def foo = s } object features extends App { implicit def wrappedString(s: String) = new WrapperString(s) println("abc" foo) }
$ scalac -d /tmp features.scala warning: there were 2 feature warnings; re-run with -feature for details two warnings found
Let's use the compiler option -feature
to display the warning details.
$ scalac -feature -d /tmp features.scala features.scala:5: warning: implicit conversion method wrappedString should be enabled by making the implicit value language.implicitConversions visible. This can be achieved by adding the import clause 'import language.implicitConversions' or by setting the compiler option -language:implicitConversions. See the Scala docs for value scala.language.implicitConversions for a discussion why the feature should be explicitly enabled. implicit def wrappedString(s: String) = new WrappedString(s) ^ features.scala:6: warning: postfix operator foo should be enabled by making the implicit value language.postfixOps visible. This can be achieved by adding the import clause 'import language.postfixOps' or by setting the compiler option -language:postfixOps. See the Scala docs for value scala.language.postfixOps for a discussion why the feature should be explicitly enabled. println(new A() foo) ^ two warnings found
Pattern definitions [↑]
// File patdef.scala object patdef extends Application { var (x, y) = if (math.random < 0.5) (1, 2) else (-1, -3) var hd :: tl = List(1, 2, 3) y *= 2 hd += 1 println(y) // prints either "4" or "-6" println(hd) // prints "2" }
Structural types [↑]
// File structs.scala class File(name: String) { def getName(): String = name def open() { /*..*/ } def close() { println("close file") } } object structs extends Application { def test(f: { def getName(): String }) { println(f.getName) } test(new File("test.txt")) test(new java.io.File("test.txt")) }
Type constructor polymorphism [↑]
trait Iterable[+T] { type MyType[+T] <: Iterable[T] // MyType is a type constructor def filter(p: T => Boolean): MyType[T] = //... def map[S](f: T => S): MyType[S] = //... } abstract class List[+T] extends Iterable[T] { type MyType[+T] = List[T] }
Tuples with arity 2 up to 22 [↑]
// File tuples.scala import TupleOps._ object tuples extends Application { val pairs = List( Pair(1015, "Lausanne"), // old style (1220, "Genève"), 1950 -> "Sion" // "->" defined in object Predef ) val buf = new collection.mutable.ListBuffer[(Int, String)] buf += Pair(1015, "Lausanne") buf += ((1220, "Genève")) // outer parenthese required! buf += 1950 -> "Sion" assert(pairs == buf.toList) val triples = List( Triple(1700, "Fribourg", "026"), (2000, "Neuchâtel", "032"), 2500 -> "Bienne" --> "032" // "-->" defined in object TupleOps ) }
For convenience pairs in Scala can be created with the predefined
method ->
(see object scala.Predef
).
Below we define our own method -->
to support the
creation of triples.
// File TupleOps.scala object TupleOps { // see scala.Predef.any2ArrowAssoc final class ArrowAssoc[T1, T2](val x: Tuple2[T1, T2]) { @inline def --> [T3](y: T3) = Tuple3(x._1, x._2, y) } implicit def pair2ArrowAssoc[T1, T2](x: Tuple2[T1, T2]) = new ArrowAssoc(x) // more implicits }
Extractor objects [↑]
// File extractors.scala object Twice { def apply(x: Int): Int = x * 2 def unapply(z: Int): Option[Int] = if (z % 2 == 0) Some(z / 2) else None } object extractors extends Application { val x = Twice(21) x match { case Twice(n) => println(n) } // prints 21 }