lua-users home
lua-l archive

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

On Sun, Jan 17, 2010 at 3:19 PM, steve donovan
<> wrote:
> On Sun, Jan 17, 2010 at 1:59 PM, Eike Decker <> 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.

There's no ambiguity, that's just the error message it *always* gives
for a statement that starts with a valid identifier followed by
anything that it doesn't expect. Are you sure you made the right
change? (I don't know enough about the Lua source to suggest anything
different, I'm afraid.)