Re: Function definitions in table constructors
[
Date Prev][
Date Next][
Thread Prev][
Thread Next]
[
Date Index]
[
Thread Index]
- Subject: Re: Function definitions in table constructors
- From: "Alex Davies" <alex.mania@...>
- Date: 2008年2月21日 23:00:42 +0900
It's quite an easy change to the parser, see:
http://lua-users.org/lists/lua-l/2008-01/msg00525.html
The patch is a little different though - for my oo system I prefer to have
implicit selfs inside table functions, just look for the comment inside
function "funcfield" to alter this behaviour. I think really it should be in
the core, given that as original poster said it's supposed to be just
syntactic sugar.
Oh, the patch also makes commas optional following an inline function.
- Alex
(P.S. my emails been really unreliable, this message didn't appear on the
list hours ago when I first tried, so I'm really hoping I won't flood the
list when whatever's causing the problem unclogs)
On Thu Feb 21 10:56 , 'Mark Meijer' <meijer78@gmail.com> sent:
I've been wondering the same thing, especially as "function foo()" is
just syntactic sugar for "foo = function()". But I'm guessing it has
something to do with how the parser is built.
I do think it would be nice to allow it. Given the fact that keywords
(such as "function") are not allowed as names (i.e. string keys using
the "table.key" or "table:key" syntax), I think it shouldn't be much
of a problem for the parser.