[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Son of Lua - Sol
- From: Roberto Ierusalimschy <roberto@...>
- Date: Thu, 01 Feb 2001 10:54:09 -0200
> Why do we have this restriction in Lua? Shouldn't "function var(...)"
> just be sugar for "var = function(...)"?
It is too complicated to do the "full sugar". For instance, you can write
foo(x,y,z).x = function (a,b,c) end
But if you try
function foo(x,y,z).x (a,b,c)
the parser would have a hard time to realize that (x,y,z) is not the
parameter list of the function.
With the options Lua gives you, you can always "factor out" the prefix
and use the sugar, like this:
obj = foo(x,y,z)
function obj.x (a,b,c)