[type-annos-observers] ordering of annotated array brackets

Michael Ernst mernst at cs.washington.edu
Tue Mar 4 17:29:57 UTC 2014


> Wouldn't it be easier to read if all of these fields had the same type:
>
> @TD String @TA [] @TB [] @TC [] test;
> @TD String @TA [] @TB [] test @TC [];
> @TD String @TA [] test @TB [] @TC [];
> @TD String test @TA [] @TB [] @TC [];

This is not desirable.

There was some text in the old specification about this issue.  It was 
commented out in September 2011 for brevity, but not because of 
controversy.

In this (deprecated but legal) syntax, in each component you read 
left-to-right, like this:

     @English String @NonNull [] [] []  arr1,   arr2 @Length(10) [] [] [];
     3-------------> 2--------------->               1------------------>

As another example, consider

     @A T @B [] arr1, arr2 @C [];

arr1 should have the same annotations as the elements of arr2.  So,

     @A T @B [] arr2 @C [];

should be equivalent to

     @A T @C [] @B [] arr2;


Using the examples quoted at the beginning of this email message, here are 
equivalence pairs:

@TD String @TA [] @TB [] @TC [] test;
@TD String test @TA [] @TB [] @TC [];

@TD String @TA [] @TB [] test @TC [];
@TD String @TC [] @TA [] @TB [] test;

@TD String @TA [] test @TB [] @TC [];
@TD String @TB [] @TC [] @TA [] test;


                     -Mike


More information about the type-annotations-spec-observers mailing list