lua-users home
lua-l archive

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


I'll be honest I don't see this as buying much … at the end of the day:

\(x,y) (x+a*y)
function (x,y) return x+a*y end

All you have done is replace "function" with "\" and have an implied return statement. Personally, I like that Lua has so FEW shortcuts .. yes, it adds typing but think how easy it is to read? And remember, EVERYONE has there own pet little "it would be nice if…" and if they were all added Lua would cease to be Lua (imho).

--Tim


On Apr 8, 2013, at 6:41 PM, oliver <oliver.schoenborn@gmail.com> wrote:

> 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