[JSR308] Revisiting array annotations

Igor Peshansky igorp at us.ibm.com
Mon Oct 15 16:00:34 EDT 2007

Michael Ernst <mernst at csail.mit.edu> wrote on 10/15/2007 03:40:01 PM:

> Sorry for my delayed response to Igor's thoughtful message; I was out
> sick at the end of last week (but am getting better now).  Let me
> address three issues first, and then devote a separate message to the
> most important issue that Igor raised.
> 1. Igor is right that the list of array syntax proposals is missing 2
> items.  Section B.3 of the proposal lays out the space of 6
> possibilities:
>  * 3 locations for annotations:  inside-brackets, prefix, postfix
>  * 2 possibilities for what the annotation modifies:  array, elements
> but then explicit enumerates only 4 (not all 6).
> I have added the two missing items.  I also changed the proposal
> numbers (1-4) to names (ARRAY-IN, ARRAY-PRE, ARRAY-POST, ELTS-IN,

Thanks, looks good now.

> 2. I lean against permitting parentheses in type specifications.  I
> fear this may change the feel of the Java language, and I want to be
> conservative in adopting such changes.  I would also like to see how
> often it is necessary in practice.  Obviously, if a compelling case
> can be made, then I am willing to change my mind.

In case it wasn't clear from my message, I lean against it as well.
We might want to address some other mechanisms for grouping type
specifications, however.

> 3. In a declaration, Java permits array dimensions to be specified
> both after the type and after the variable, as in this identity
> function on 2-D arrays of Integers:
>    Integer[] id(Integer[] x []) [] { return x; }
> This syntax was probably motivated by C syntax.  My feeling is that
> use of the brackets after the variable is relatively rare and is
> usually bad style, so we should focus first on what makes sense and is
> readable for the more standard declarations, such as
>    Integer[][] id(Integer[][] x) { return x; }
> and only then worry about accommodating the other case.

The syntax for variables was certainly motivated by C.  It's unclear
why the same syntax was adopted for methods -- perhaps for symmetry.
C does not allow putting the brackets after the parentheses (in fact,
returning arrays is not allowed in C).

I agree that we shouldn't worry overmuch about this corner case.
Igor Peshansky  (note the spelling change!)
IBM T.J. Watson Research Center
XJ: No More Pain for XML's Gain (http://www.research.ibm.com/xj/)
X10: Parallel Productivity and Performance (http://x10.sf.net/)

More information about the JSR308 mailing list