[Grace-core] Precedence of multi-part method names

Michael Homer mwh at ecs.vuw.ac.nz
Fri May 27 17:40:32 PDT 2011


On Sat, May 28, 2011 at 11:19 AM, Kim Bruce <kim at cs.pomona.edu> wrote:
> If I'm understanding this correctly, the problem occurs only (primarily?) with mixfix parameters.  I'm happy to treat mixfix parameters as being equivalent to other cases with multiple parameters, thus requiring parentheses.  Thus only methods with a single parameter can be applied without parameters (I would treat curly brackets as having implicit parentheses around them).   Thus o.m arg is fine, o.m arg restOfm args would not be fine (if restOfm is part of the parameter name).

It's only with mixfix, or at least only when it looks like there's
mixfix.  Mostly it's the difference between:
 var x := y.at(1)
 if x then { ...
and
 if y.at(1) then { ...
which at first sight should be identical.

Another place it could be a problem is with operators. This:
 sin x < cos y
looks like it should work, meaning:
 (sin x) < (cos y)
but then:
 if x < y then
means:
 (if x) < (y then)
My compiler doesn't hit that at the moment, but it would if it allowed
unparenthesised method requests. Both cases seem like they ought to be
valid, but they're syntactically the same.

There are some more pathological cases as well, especially in the
"looks like mixfix" line. Something like "f g h i" is arguably legal,
meaning f(g(h(i))), but it's ambiguous with f(g)h(i) (and wouldn't be
bad to ban in any case).
-Michael


More information about the Grace-core mailing list