[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Makes funcname in Lua same as var? (lua syntax)
- From: Roberto Ierusalimschy <roberto@...>
- Date: Fri, 11 Feb 2011 09:15:19 -0200
> > var there can lead to some confusion:
> >
> > function f(x)[1](y) end
> >
> > because parenthesis are used in multiple ways in Lua (as well as in
> > math): expression grouping, function calls, and function argument
> > lists.
> >
> > is this confusion?
> function foo() end is the semantics sugar of foo = function() end
> so function f(x)[1](y) end is the semantics sugar of f(x)[1] = function(y)
> end
It is confusing for the parser, which will need unlimited look-ahead.
(I think it is confusing for people, too, but I will not argue that.)
Consider:
function f(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s).x(a) return a end
function f(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s) return a end
The parser needs to read some 40 tokens before knowning whether the
first 'f' is the name of the new function or a call.
-- Roberto