[JSR308] annotations on arrays
perry.dsrg at gmail.com
Tue Jan 30 18:04:36 EST 2007
You're right that parsing raises an issue, since the grammar defines an
*@* TypeName [( [Identifier =] ElementValue)]*
One possibility would be to use a comma (or [semi]colon or some other
punctuation) between the annotation and an assignment expression and not
requiring punctuation when there's no assignment.
Keeping all of the description of a dimension within the brackets and
having no extra punctuation in a very common case seems desirable.
Is this workable? How do you find the notation?
perry at dsrg.org
On 1/30/07, Eugene Kuleshov <eu at javatx.org> wrote:
> Apparently annotations on arrays is quite hot topic and even I very
> much would like to avoid it, there is one thing worth to mention.
> The prosed syntax is suggesting to introduce array annotations like
> Document[@Readonly] docs5 = new Document[@Readonly 12];
> The problem I see with this syntax is that it may interfere with the
> expression used for array dimensions. Java language currently allow to
> write something like this:
> int n;
> Document d = new Document[n = 5];
> and we may end up with something like new Document[@Readonly n = 5],
> which doesn't seem allow to identify if annotation belong to the array
> element or to the expression defining its index or dimensions.
> So, it is probably more consistent if annotation declaration would be
> outside of the square brackets. Then above example would look like this:
> Document @Readonly  docs5 = new Document @Readonly ;
> JSR308 mailing list
> JSR308 at lists.csail.mit.edu
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the JSR308