lua-users home
lua-l archive

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


2010/11/26 Pierre-Yves Gérardy <pygy79@gmail.com>:
> On Fri, Nov 26, 2010 at 23:49, Doug Lua <douglua@dkrogers.com> wrote:
>>  \x,y,z(x*y+z)    --> function(x,y,z) return x*y+z end
>>
>> It's concise and seems to have the fewest (zero?) ambiguities.
>
> It doesn't support statements. Just one expression list to be
> returned. It's useless if you want to use it for delayed execution of
> code blocks.

See Tony Finch's modified version of this syntax. He's also got the
patch to modify the Lua and LuaJIT 2 parsers on github:
http://article.gmane.org/gmane.comp.lang.lua.general/70923

To quote from his message:

  function ::= function `(´ [parlist] `)´ <block> end
             | `\´ [parlist] `(´ [explist] `)´
             | `\´ [parlist] <funbody>

  funbody  ::= <function> | <dostat> | <ifstat> | <loopstat>

which would allow

  each = \ f \ t for k,v in pairs(t) do
                   f(k,v)
                 end

Alex