[JSR308] annotations on arrays

Chin Wei Ngan chinwn at comp.nus.edu.sg
Thu Feb 1 18:11:17 EST 2007



On Thu, 1 Feb 2007, Neal Gafter wrote:

> 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.

I have a slightly different view on this. If we view array as
a composite type, the bounds of arrays are in fact "int" field
of array object. Hence, bound/dimension _is_ a component of the
type of array. The only difference is that bound is always an
int type in Java, so there is no need to explicitly re-declare it.
That is Java is silent on this bound type in its syntax.

In some languages, such as Haskell, they allow indexes to be
other types, as long as they are enumerable and you have to explicitly
state the type for index/dimension.




More information about the JSR308 mailing list