lua-users home
lua-l archive

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


In message <CAPweGw7Xza1tZhXz_NXzMXpz=oNc6P2q_LvtPHGjejwEzG_zog@mail.gmail.com>
          Egor Skriptunoff <egor.skriptunoff@gmail.com> wrote:

>I'd like to suggest to treat
>{ function a() end }
>as equivalent of
>{ a = function() end }
>
>Such sugar would be useful in metatable constructors and in OOP.
>It would not break old code: new syntax was a syntax error in previous Lua
>versions.

May I register mild, very mild, disagreement? It hinges on the word 'useful'.
The only use that I can see of this particular syntactic sugar is to
delay the acceptance of higher order languages by those who have been
brought up solely on first-order languages. In other words, from the
educational point of view and for assisting clarity of understanding, not
useful at all.

A more cogent argument for your suggestion, IMHO, is consistency.
My personal taste is to ignore this particular sugar anyway. It has a
slight smack of dishonesty. Tell users to be brave and face up to the
fact that functions are first-class citizens!

--
Gavin Wraith (gavin@wra1th.plus.com)
Home page: http://www.wra1th.plus.com/