Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Which syntax options/language features did Scala remove over time (and why)? [closed]

The title pretty much sums up my question.

The deprecation and removal of case class inheritance is a pretty new one, and I wonder which things got removed/substantially changed before that. I remember something about val in for loops and a different name for object as well as some requires keyword.

I would love to see code examples of how things were used/how they were replaced later, with an actual version when it happened and with a rationale why!

PS: One item per answer seems to be a good idea!

like image 653
soc Avatar asked Jul 25 '11 09:07

soc


2 Answers

Case class inheritance was a short-lived feature: It was introduced in 2.7, deprecated in 2.8/2.9 and finally removed in 2.10.

Example:

case class Foo(a: Int, b: Int)
case class Bar extends Foo(42, 43)

The problem was that the automatically supplied equality implementations didn't really work in the face of inheritance, therefore this feature was removed.

Removing case class inheritance has also a good effect: It will allow supplying better typed product*** methods by inheriting the concrete ProductN trait:

val f = Foo(1,2).productIterator
f: Iterator[Any] = non-empty iterator // < 2.10
f: Iterator[Int] = non-empty iterator // 2.10 with -Xexperimental
like image 85
soc Avatar answered Sep 28 '22 05:09

soc


It was possible in Scala 2.7 to declare things of type int (no capital "I"). Since Scala does not support the idea of primitive values and tries to be as consistent with everything as far as it can, this "feature" is deprecated.

like image 30
agilesteel Avatar answered Sep 28 '22 04:09

agilesteel