lua-users home
lua-l archive

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


There is not much that I really miss in Lua, but the lack of a short lambda syntax is one that keeps coming back time and again. When the text around an _expression_ is 5 times longer than the _expression_ it encloses, the code gets obfuscated; it should be unnecessary in a language where functions are objects.

The technique (described on the Lua wiki) involving a text string and loadstring function is not adequate; the quotes make it look unnatural, it is jarring; metalua is not an option; and there doesn't seem to be any hooks that would allow me to create a DLL to extend the Lua syntax. 

But I know many of you know the compiler intimately; what would be the simplest syntax that would involve the least modification to lua/luac/libs (such as the library that saves/reads bytecode)? Some examples: 

    \(x,y) [x+a*y]
    @(x,y) (x+a*y)
    \\(x,y) x+a*y\\
    [(x,y) x+a*y]

The last one seems quite natural fit in Lua, it is akin to table keys (which can be surrounded by square brackets when the string has spaces). 

Any input appreciated.
ols