Proposal: Simplified syntax for dealing with parameterized types.

brucechapman at paradise.net.nz brucechapman at paradise.net.nz
Mon Mar 23 14:46:48 PDT 2009


Quoting james lowden <jl0235 at yahoo.com>:

> 
> Proposal: Simplified syntax for dealing with parameterized types.
> 
> AUTHOR(S):
> 

- snip-
> [modifier_list] interface [name] = [superinterface] <list_of_types. .
> .>;
> 
> is de-sugared to:
> 
> [modifier_list] interface [name] extends [superinterface]
> <list_of_types. . .> {}
> 
> 
> Classes are a bit more complex:
> 
> [modifier_list] class [name] = [superclass] <list_of_types. . .>;
> 
> is de-sugared to:
> 
> [modifier_list] class [name] extends [superclass] <list_of_types. . .>
> {
> 
>  [constructors]
> 
> }
> 


my 2 cents:

The interface case is trivial and offers little or no value in terms of added
expressiveness other than an alternative syntax consistent with the class case,
which is more than enough value IFF the class case can be justified.

The class case can be achieved using a custom annotation, and an
AnnotationProcessor to generate the code. Such a solution would be nicer if
annotation values could include type literals, but can still be done nice enough
to be "adequate for purpose" (IMHO) without them. 

The annotations could be placed in package-info.java giving you much of the
advantage of your param-types.java file.

So a proposal for type literals and type literals as annotation values would
make this proposal redundant, and enable solutions to similar (and not so
similar) needs as well. However good this proposal is, type literals as
annotation values is even better, because it leverages existing mechanisms to
allow developers to solve many problems themselves, as opposed to having the
compiler solve one problem.

Bruce



More information about the coin-dev mailing list