[JSR308] annotations on arrays

Perry James perry.dsrg at gmail.com
Tue Jan 30 18:04:36 EST 2007


Hi Eugene,
   You're right that parsing raises an issue, since the grammar defines an
annotation as

*Annotation:
        *@* 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

==
Perry James
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
> this:
>
>   Document[][@Readonly] docs5 = new Document[2][@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[2] @Readonly [12];
>
>   Thoughts?
>
>   regards,
>   Eugene
>
>
>
> _______________________________________________
> JSR308 mailing list
> JSR308 at lists.csail.mit.edu
> https://lists.csail.mit.edu/mailman/listinfo/jsr308
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: https://lists.csail.mit.edu/pipermail/jsr308/attachments/20070130/2d5f94eb/attachment.htm


More information about the JSR308 mailing list