[grammarians] ambiguity with method call?
Terence Parr
parrt at cs.usfca.edu
Tue Nov 29 15:59:53 EST 2005
Howdy,
What does
foo [1]
parse as? foo could be a variable and then foo is a simple array var:
foo = [a,b]
foo[1]
If foo is a method, it could return an array and then you could
access the 1st element:
def foo
return [a,b]
end
foo[1]
It could also be a method with args:
def foo x
...
end
foo [1] # same as foo([1])
This 5x ways to do anything syntax is truly a burden for the
implementor (and as a user one of the reasons I hated perl).
Regardless, is this a true *syntactic* ambiguity as I suspect? I.e.,
you need to simply pick an interpretation by dictum in the manual?
Thanks,
Ter
More information about the Rubygrammar-grammarians
mailing list