[JSR308] Others possible syntaxes for type annotations

Neal Gafter gafter at google.com
Thu May 17 00:37:46 EDT 2007


Yes.  I have in mind a uniform and unambiguous annotation syntax for types
(essentially a single production), statements (ditto), and declarations, and
I hope to provide a parser along with my description of the syntax.

On May 16, 2007 4:40 PM, Eugene Kuleshov <eu at javatx.org> wrote:
>
>
>  I am not sure if type aliasing is either a good idea or in scope of
> the JSR 308. Though it is been considered a bad idea to add new keywords
> to Java language, including "typedef" or "syntax".
>
>  As for alternative syntaxes, I spoke to Neal Gafter at the JavaOne
> last week and he explained his idea for non-ambiguous syntax for
> annotations to me. He was planning to send his proposal along with Java
> language grammar changes to this list.
>
>  regards,
>  Eugene
>
>
>
> Maxim Kizub wrote:
> > Hello.
> >
> > For type annotations there may be others syntax solutions, not only
> > prefix vs postfix.
> >
> > First, annotations may be seen as "external" type parameters. This can
> > be expressed as
> >
> > Type<@NonNull> or List<String, @ConcurentAccess("write")> (or maybe
> > use ; to separate arguments and annotations)
> >
> > Next, type annotations may be shortened using typedefs, like
> >
> > typedef StringNN String<@NotNull>;
> > typedef String0 String<@Nullable>;
> >
> > I tried to use typedefs (in my KievCompiler, which is used now as the
> > core language for SymADE project, http://www.symade.org),
> > but found, that much more useful (for me) were postfix operators for
> > types, defined by typedefs. For instance, we can define
> >
> > typedef type? type<@Nullable>;
> > typedef type! type<@NotNull>;
> > typedef type# type<@Immutable>;
> >
> > and then we can use operators on any type or combine multiple postfix
> > operators together
> >
> > String? (equivalent to String<@Nullable>)
> > String!# (equivalent to String<@NotNull, at Immutable>)
> >
> > The same "type operator" definition syntax can be unified and used for
> > all type parameters, for instance,
> >
> > typedef tp& WeakRef<tp>;
> >
> > will allow define weak references using & postfix type operator. Of
> > cause, since there is little ASCII operators left,
> > it will be better to allow unicode operators (punctuation,
> > mathematical, arrows, technical symbols and others
> > unicode subranges).
> >
> > Actually, [] and ... may be seen as "standard" type operators defined as
> >
> > typedef type[] java.lang.Array<type>;
> > typedef type... java.lang.Vararg<type>;
> >
> > Also, since typedefs are expected to be common for the whole project,
> > java can have special import for syntax,
> > i.e. like it has "import static ...;" we may add "import syntax ...;"
> > and record typedefs (as well as common imports for
> > the project) in the named section (in KievCompiler I also use "import
> > syntax" to define operators - unicode image
> > plus priority, arity and association).
> >
> >
>
>
> _______________________________________________
> JSR308 mailing list
> JSR308 at lists.csail.mit.edu
> https://lists.csail.mit.edu/mailman/listinfo/jsr308
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: https://lists.csail.mit.edu/pipermail/jsr308/attachments/20070516/40ba414c/attachment.html


More information about the JSR308 mailing list