[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: RE: Multiple Questions
- From: "Virgil Smith" <Virgil@...>
- Date: Fri, 11 Jun 2004 12:59:33 -0500
>>>1) Why is only one function declaration syntax supported in tables?
>>Sounds like a bug to me.
>I don't think it's a bug, but a parser's restriction.
OK, here's the deal (I think). Lua's syntax has lots of "sugar" and this
case piles "sugar" on top of "sugar" and that's not healthy.
Consider
t = { a = 1, b = 2 }
is equivalent to...
t = { ["a"] = 1, ["b"] = 2 }
So in...
MyClass = {
function MyFunc() end;
}
You've got two different "sugar rules" and their either not being handled as
true replacements or they are not being handled in the right order of
evaluation.
There, now I've explained why its not a trivial bug, but one that has
probably been hit numerous times, but not worth anyone's efforts to fix as
its much easier to just redefine it.
Also, I think people you <knowingly> use Lua a lot fall out of the habit of
using the function Name() form and always use the Name = function form.
This is much more consistent with actively thinking of functions as values
(And thus what you can do with them).