11 Feb 16:34
Re: [ANN] Scala 2.7.0-RC1
Lex Spoon <lex <at> lexspoon.org>
2008-02-11 15:34:31 GMT
2008-02-11 15:34:31 GMT
Alex Boisvert wrote:
> I see no mention of type annotations in the language changelog. Could
> you elaborate?
(Followups to gmain.comp.lang.scala)
For several months, I worked on optional support in scalac for
annotations on types. The support was only turned on if you compiled
with -Xplug-types. Now, the option is gone and you always get the support.
This is a pretty good foundation, I think, for the pluggable type
systems that Gilad Bracha describes. The work is supported by the
Hasler Foundation, so hopefully they think it is a pretty good
foundation, too. :)
There are two interesting parts to it compared to Java annotations. One
is that you can put arbitrary type-checked expressions in your
annotations, not just constants. So @dim(Length/Time) is perfectly
valid. Second, there is sophisticated support for propagating type
annotations through the type inference. Here is a typical example:
object Foo {
val x = 3
val y: Int @GreaterThan(x) = 10
}
val z = Foo.y // inferred type is Int @GreaterThan(Foo.x)
Notice how the @GreaterThan(x) had to be rewritten as
@GreaterThan(Foo.x). Let me tell you, that was a long saga to get
(Continue reading)
RSS Feed