[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Class:function problem
- From: "Russell Y. Webb" <rw20@...>
- Date: Thu, 13 Jul 2000 08:10:13 -0700
Should this kind of thing be a warning or error that you can turn off
either when Lua is started or via a #define when Lua is compiled? Of
course then you create different states for Lua that are needed to compile
different code --- probably a bad idea unless these were flagged as
warnings and the warnings were by default turned off.
I guess a list of simple lua modifications on the website could include
this one.
Personally I think the code below is sensible and clean --- it would be
nice if the language would allow it.
Russ
>>This code doesn't:
>>--------------------------------
>>$debug
>>
>>myFunc = function ()
>> Test = {}
>> function Test:init() end
>>end
>>--------------------------------
>>
>>Lua says:
>> lua error: `end' expected (to close `function' at line 3);
>> last token read: `function' at line 5 in file `test.lua'
>
>Lua 4.0 says:
>error: cannot nest this kind of function declaration;
> last token read: `function' at line 5 in file `(stdin)'
>
>So, this is a feature :-)
>It might be a bad feature: it's a kind of "hand-holding", helping the user.
>We think it might be a user error, as 3.2 said:
> `end' expected to close `function'.
>This might happen if you really forgot the `end', as in
>
>function myFunc()
> Test = {}
>
>function Test:init()
>end
>
>The identation here implies a different intention by the user and there's
>really
>an `end' missing to close `function' myFunc.
>
>Perhaps this "hand-holding" isn't that useful...
>
>>I thought "a:b()" was syntaxical sugar for "a.b(a)"(?)
>
>Yes, for calls, yes. For definitions, it works only in the outer level.
>--lhf