lua-users home
lua-l archive

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


On Sun, Jan 31, 2010 at 6:24 PM, Peter Cawley <lua@corsix.org> wrote:
> On Sun, Jan 31, 2010 at 6:14 PM, Norman Ramsey <nr@cs.tufts.edu> wrote:
>>  > Is it possible that 5.2 could allow syntax like:
>>  >
>>  > table={
>>  > function hello(self)
>>  >   doStuff(self)
>>  > end,
>>  > hi=6
>>  > }
>>
>> While this syntax might be slightly better than
>>
>>     table={
>>     hello = function(self)
>>       doStuff(self)
>>     end,
>>     hi=6
>>     }
>>
>> I don't see it as *enough* better to be worth adding extra syntax.
> The syntactic sugar "function x" => "x = function" is meaningful at
> the statement context, and is currently done at the statement context.
> The sugar is not meaningful at the expression context, and is
> currently not done at the expression context.
> The sugar is meaningful at the field context, but is currently not
> done at the field context.
>
> Thus I see the extension of the sugar as *enough* better because while
> it does add a new syntax rule, it makes the overall syntax more
> consistent.
>

I would agree with this. In the same spirit, I think that if the
"function :name() ... end" sugar were to be allowed for defining a
method (as the original post mentioned), it should also be supported
as a statement. In particular, that would be useful inside 5.2's new
"in context do ... end" block.

-Duncan