[JSR308] annotations on arrays
gafter at google.com
Thu Feb 1 13:43:48 EST 2007
The dimensions of an array type are not part of the array type in Java (all
arrays are indexing using int, and the bounds of the array are not part of
the type), so I see annotating the "dimensions" as being somewhat out of
scope for the JSR. At best an annotation on the array type could give some
information about the values that can be used to index arrays of that type.
It could be in scope if we open the scope of the JSR to include more of the
semantically meaningful nonterminals than just types.
On 1/30/07, Chin Wei Ngan <chinwn at comp.nus.edu.sg> wrote:
> > Message: 5
> > Date: Tue, 30 Jan 2007 15:57:16 -0500
> > From: Eugene Kuleshov <eu at javatx.org>
> > 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 ;
> > Thoughts?
> > regards,
> > Eugene
> Yes, I agree much with what Eugene said that we should
> distinguish annotation for the dimensions vs annotation for
> the elements. The space within [..] should be for annotating
> the index, eg. the example that Michael raised on dependent
> type system:
> where Length annotation are meant as qualifiers to the indexes.
> To talk about the elements, it has to be done outside of
> the [..]. In general, we can view
> Document as (((Document)))
> If we allow annotations after a type, instead of before,
> we may write annotations to the above as:
> (((Document ann1) ann2) ann3)
> where ann1 is for all documents, ann2 is for
> the array of documents, while ann3 is for array of array of documents.
> I guess post-annotation would correspond to what Eugene suggested,
> and if we drop the brackets would look like this:
> Document ann1  ann2  ann3
> I guess brackets are always allowed to mininise ambiguity.
> One question may be if we should allow post-annotation
> (annotation after a type) in addition to pre-annotation
> (annotation before a type).
> JSR308 mailing list
> JSR308 at lists.csail.mit.edu
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the JSR308