[Jsr308-statements] annotations on code blocks
Eugene Kuleshov
eu at javatx.org
Sat Feb 3 12:42:45 EST 2007
Trevor Harmon wrote:
> Yes, but that's because there's a semantic difference between:
>
> @MyAnnotation int foo() { }
> and:
> int foo() @MyAnnotation { }
>
> (The first one annotates the method declaration, while the second one
> annotates the return type.)
>
> In contrast, I don't see any semantic difference between these:
>
> @ReadOnly for(...) { ... }
> for(...) @ReadOnly { ... }
> for(...) { ... } @ReadOnly
>
> Anyway, my point is that throughout Java 5 and 6, annotations have
> been exclusively prefix, so if it's only a question of syntax and not
> of semantics, we should continue the prefix tradition.
I agree that it would be nice to follow existing tradition. Though it
has been pointed out that prefix annotations don't work too well for
annotating types and I attempted to try how postfix annotations would
work for all newly introduced locations.
regards,
Eugene
More information about the Jsr308-statements
mailing list