Changes to Generics

The Grace 0.7.0 specification replaces the use of angle brackets for generic type arguments Foo<o> with double square brackets: Foo[[o]].

This change only affects the syntax of the language, not the semantics. Generic arguments remain optional, and if not supplied have the Unknown type.

*          *          *          *          *

The reasons for this change are to make Grace programs easier to read (for people) and to parse (for programs). Using the old syntax, for example, code such as:

could call a one-argument method run passing the result of a generic call a<B,C>(1), or it could call the two-argument method run, with arguments a<B and c>(1).

The new syntax resolves these cases clearly. Compare:

with

*          *          *          *          *

At the time of this post, no Grace implementation supports this new syntax.

Leave a Reply

Your email address will not be published. Required fields are marked *