11

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!

soc
  • 27,983
  • 20
  • 111
  • 215
  • Many syntax changes are listed in the appendix of the [ScalaReference](http://www.scala-lang.org/docu/files/ScalaReference.pdf). – Debilski Jul 25 '11 at 11:04

6 Answers6

5

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
soc
  • 27,983
  • 20
  • 111
  • 215
3

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.

agilesteel
  • 16,775
  • 6
  • 44
  • 55
  • 2
    Afaik most community members didn't like the fact that some types started with a lowercase and some with uppercase, they "standardized" around uppercase around 2.8 ... – soc Jul 26 '11 at 07:46
3

requires clause was deprecated in version 2.6.

trait A requires B {
  ...
}

is now written as:

trait A { self: B =>
  ...
} 

I don't know the rationale behind this syntax change. I personally find the requires syntax a tad bit more readable.

missingfaktor
  • 90,905
  • 62
  • 285
  • 365
  • 1
    I'm guessing here, that it didn't fit well with something like `trait A extends B requires C with D` and so on...You probably would need a lot of parenthesis there to make it clear what requires what and so on... – agilesteel Jul 27 '11 at 10:12
2

I don't know all the details offhand, but there is an extremely detailed version history starting here:

http://www.scala-lang.org/node/155

Practically every item that went into every release is listed. Many have links to JIRA tickets.

It might take a while to mine this data, but I suspect most of what you are looking for is there. What you might not see in detail are the rationales for deprecation, but if a JIRA ticket is given or an indication of the feature is at least written down, a web search on that topic should lead to a discussion page and rationale.

Ray Toal
  • 86,166
  • 18
  • 182
  • 232
  • 3
    There is also the "Scala language changes" page: http://www.scala-lang.org/node/43 What I'm looking for are some concrete examples and the rationale behind it... – soc Jul 25 '11 at 09:57
  • This is a much better link then the one I put in my answer. I looked at a couple removed features (`scala.compat.math` and `assertSame`) and it does look like finding out the reasons for deprecation in many cases is going to be hard. So great idea soliciting input here! – Ray Toal Jul 25 '11 at 14:56
2

The for comprehensions used the keyword "val" before each generator. The next Scala version will no longer have this, but, presently, the following deprecated syntax is still accepted:

for (val i <- 1 to 10) yield i

This was just deemed unnecessarily verbose.

Daniel C. Sobral
  • 295,120
  • 86
  • 501
  • 681
0

Class literals (different from classOf[]) were removed from the language, but I couldn't figure out how they looked like, but probably like their Java equivalent .class.

soc
  • 27,983
  • 20
  • 111
  • 215