Revisited Scala Change History

by Stephane Micheloud, June 2009

[Home]
[Back]

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
  • New Scala reflection API (scala.reflect.ClassTag instead of scala.reflect.Manifest).
  • scalac now issues a warning for language features such as implicit conversions, reflective calls and postfix operators. [1]
  • Usage of macro and then as identifiers is deprecated (now reserverd words).
  • Deprecated "dot" syntax for real numbers (write "1.0f" instead of "1.f").
  • Deprecated ScalaObject trait (was added to Scala-compiled classes).
  • Added annotation @unspecialized
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
  • Parallel collection library (package scala.collection.parallel).
  • Type parameter spezialization (annotation @specialized).
  • Runtime system routines (package scala.sys) to manage processes, system properties, etc.
  • The App trait is a safer, more powerful alternative to the previous Application trait, which has now been deprecated.
  • Generalized try-catch-finally construct.
2.8.2.final 2011-09-27 maintainance release
2.8.1 2010-11-09
  • The JavaConversions object (SLS 24.18) replaces the scala.collection.jcl package.
2.8.0 2010-07-13
  • Trailing commas in expression, argument, type or pattern sequences are no longer supported.
  • Predef.classOf[C] is now a constant expression (SLS 6.24); previously (since 2.1.5) it designated a class literal.
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
  • Change in scoping rules for wildcard placeholders in types
  • No contractiveness requirement for implicits
2.7.0 2008-02-07
  • Java generics are now supported by default
  • added companion extractor object to case classes
  • Case classes can now be inherited, can be declared abstract, and accept companion objects.
  • The default target platform for object files is now jvm-1.5 (was jvm-1.4, see compiler option -target:<target>).
2.6.1 2007-11-30
  • Both var and val are now accepted in pattern matching definitions [2].
2.6.0 2007-07-27
  • Existential types (declared using the new keyword forSome)
  • Lazy values (declared using the new modifier lazy)
  • Structural types (declared using type refinements) [3]
2.5.1 2007-06-13 maintainance release
2.5.0 2007-05-02
  • Type constructor polymorphism [4]
  • Early object initialization
  • Scala libraries now support OSGi
  • Package scala.actors is now part of the standard Scala library
2.4.0 2007-03-21
  • The primary constructor of a class can now be marked private or protected
  • The syntax for tuples has been changed from {...} to (...) [5]
  • It is now possible to combine operators with assignments.
2.3.3 2007-01-26 maintainance release
2.3.2 2007-01-23
  • It is now possible to define patterns independently of case classes [6].
  • The collection library has been extended.
2.3.1 2006-12-06 maintainance release
2.3.0 2006-11-23
  • Simplified syntax for procedures (aka. functions returning Unit)
  • Distinction between type variables and types as type arguments in patterns
  • Bottom classes All/AllRef in Scala's type hierarchy renamed to Nothing/Null
2.2.0 2006-10-11
  • The collection library has been extended.
2.1.8 2006-08-23
  • added visibility qualifier for protected
  • relaxed private access for companion modules/classes
  • The lookup method for implicit definitions has been generalized
2.1.7 2006-07-19
  • Multi-Line string literals
2.1.6 2006-06-16
  • Added support for Java annotations.
  • Merged shell commands scalaint and scalascript with the command scala.
2.1.5 2006-05-24
  • There is a new syntax for class literals (classOf[C]
  • Added the shell command scalascript to execute Scala scripts.
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
  • sbaz is now part of the Scala distribution.
2.0 2006-03-12
  • Implicit parameters (replacing views in Scala 1.0).
  • New keywords implicit, match and requires.
  • Newlines can now be used as statement separators in place of semicolons.
  • For-comprehensions now admit value and pattern definitions.
  • A class parameter may now be prefixed by val or var.
  • Relaxed rules of implicit conversion and method overriding with respect to empty parameter lists.
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
  • Support for Scala attributes
1.3.0.10 2005-03-07
  • Objects of arbitrary type can now be used in XML literals.
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
  • .NET support
1.2.0.1 2004-07-27
  • XML namespace handling.
1.2.0.0 2004-06-09
  • Views
  • XML literals
  • Full Unicode support in identifiers and XML names.
1.1.1.3 2004-04-15
  • Partial Unicode support in identifiers.
1.1.1.0 2004-03-23
  • Support for Java's static inner classes.
1.1.0-b3 2004-02-19 maintainance release
1.0.0-b4 2004-01-12
  • Base class scala.Object was renamed to scala.ScalaObject and changed to an interface.
1.0.0-b2 2003-12-08
  • Value classes are now direct subclasses of scala.AnyVal

Examples

  1. 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
    
  2. 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"
    }
  3. 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"))
    }
  4. 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]
    }
  5. 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
    }
  6. 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
    }

References

  1. The Scala Language Specification (SLS), Version 2.8
    Martin Odersky, November 2010

About the Author

Stephane's Picture
Stéphane Micheloud is a senior software engineer. He holds a Ph.D in computer science from EPFL and a M.Sc in computer science from ETHZ. At EPFL he worked on distributed programming and advanced compiler techniques and participated for over six years to the Scala project. Previously he was professor in computer science at HES-SO // Valais in Sierre, Switzerland.
[Top]

Other Articles