list literal gotcha and suggestion

Mark Thornton mthornton at optrak.co.uk
Thu Oct 1 13:46:19 PDT 2009


Tim Peierls wrote:
> That would make for an awfully exciting type system.
>
>     Paris in the
>     the spring.
>
> Quick, sentence or not?
The The ;-)

Allowing an immutable List of constants to also be a Set doesn't seem 
too surprising to me. In fact the original proposal might be more 
surprising. From the original proposal:

final Set<Integer> primes = { 2, 7, 31, 127, 8191, 131071, 524287 };

The order of iteration of 'primes' is undefined. With my suggestion

final Set<Integer> primes = [2, 7, 31, 127, 8191, 131071, 524287];

Here the iteration order is as listed because the value will also 
implement List.

Mark Thornton




More information about the coin-dev mailing list