lua-users home
lua-l archive

Re: in-do-end

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Sun, Jan 17, 2010 at 1:59 PM, Eike Decker <zet23t@googlemail.com> wrote:
> That wouldn't be a problem since "function g(x)" is a statement to
> assign a function that is currently defined to the global value "g",
> whereas "function (x)...end" is no valid statement at all, unless it
> is being a part of an argument or a value to be assigned to a
> variable.
Very true! It being a rainy afternoon, I modified the parser to
accept anon functions as arguments. In the function funargs in
lparser.c, added another case:
 case TK_FUNCTION: { /* funcargs -> function */
 luaX_next(ls);
 body(ls, f, 0, ls->linenumber);
 break;
 }
> print function() end
stdin:1: '=' expected near 'function'
Oops - ambiguity - it thinks this is an assignment! Not as easy as it looks.
steve d.

AltStyle によって変換されたページ (->オリジナル) /