Scala Annotations
Viewing old version 660a7959f27561981ce7cbe6be98e7dd8f6868f4; View Current
The Gist
Annotations gives a pretty decent overview of how annotations are used in Scala.
My Interpretations
Annotations in Scala are conceptually the same as they are in Java. Many of the Java keyword modifiers are annotations in Scala (as opposed to language constructs). For example, native in Java is the annotation scala.native.
For the purposes of interacting with Java, Scala classes may annotate methods with the throws annotation. This is the equivalent of the the throws keyword in Java and lets the Java compiler know what exceptions must be caught.
Java Annotations, when used in Scala, are specified using one of two types of syntax:
My Thoughts on this Feature
I’ve never felt like annotations were a particularly good addition to Java; they always seemed like a hack to support poorly designed frameworks like J2EE and JAX-RS. I don’t know how endemic they are to Scala at this time, so lets hope they don’t get used much. Scala is a much more expressive language than Java and I think it can get by without annotations being used all over the place.
Also, the use of parens vs. braces seems needlessly inconsistent.
Last Updated 08/22/2009 at 09:36:30 AM by davec
blog comments powered by Disqus
All Content by David Copeland is licensed under a
Creative Commons Attribution-Noncommercial-Share Alike 3.0 United States License.