ARM syntax and new keywords
david.goodenough at linkchoose.co.uk
Thu Nov 26 10:30:20 PST 2009
On Thursday 26 November 2009, Neal Gafter wrote:
> On Thu, Nov 26, 2009 at 6:31 AM, Jonathan Lawson
<jonty.lawson at gmail.com>wrote:
> > A pretty long post I'm afraid, but I hope it is contributing something of
> > value.
> > I've been following the discussions about ARM and a question about the
> > syntax has been niggling at me: wouldn't it be better using a new
> > keyword?
> Now that jdk7 will include a syntax for using names that are otherwise
> keywords (the syntax is #"name"), the backward-compatibility breakage of
> adding a new keyword is much less severe. Also, context-sensitive
> are a true-and-tried technique, just not used yet in Java.
I hope that the # operator will be available for both methods and fields.
This was discussed early on in the Coin process, in my lightweight properties
proposal. It is really the only bit of that proposal that is needed, the rest
can be done in other ways.
Actually it is a little more complicated than for methods. For the simple
case of Class#field you can return a java.lang.reflect.Field
object, but if you have a chain of # operators you would need a Field,
and if you wish to bind it to an object you need to remember that object,
then the result will been to be wrapped in a new
object (FieldRef is the best name I have seen). The compilation requirement
is simple, object[#field] becomes new FieldRef(object[,"field"]) where
object can be an object or a class, and  means repeated as necessary
with at least one present. The compiler would need to check that field
exists in object (and on down the chain) regardless of whether this is
a private/protected/public field.
More information about the coin-dev