lua-users home
lua-l archive

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


Ah well, that's different as lazy evaluation is dramatically different behavior, and would merit a different syntax imho.

On Apr 8, 2013, at 9:09 PM, Paul K <paulclinger@yahoo.com> wrote:

> 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?

I tend to agree, but there is one place where a short notation may be useful: lazy and delayed evaluation (http://lua-users.org/lists/lua-l/2006-12/msg00241.html, http://lua.2524044.n2.nabble.com/Scheme-s-quot-delay-quot-function-in-plain-Lua-td5685776.html, and http://metalua.blogspot.com/2007/04/lazy-streams.html).

Both metalua and GSL-shell support "|a,b| a+b" notation (http://www.nongnu.org/gsl-shell/doc/intro.html#short-func-notation), which allows to use delay(|| a+b) instead of
delay(function() return a+b end) (assuming a and b are upvalues, not parameters).

Paul.

On Mon, Apr 8, 2013 at 8:51 PM, Tim Hill <drtimhill@gmail.com> wrote:
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