|
To return to Oliver's question, I think short-function syntax makes particular sense with _interactive_ work. For instance, Francesco Abbate's gsl-shell[1] uses the |x| x+1 short form popularised by metalua to great effect, since one's often creating short functions.The point is that interactive usage requires finger-friendly syntax that you would not necessarily want in formal code, much as in English contractions like "it's" are not so appropriate in reports.There are a number of ways to get that informal style. You can use metalua itself interactively. Or use LuaMacro, which does not care about which Lua version is used:LuaMacro $ lua52 luam -iLua 5.2.2 Copyright (C) 1994-2013 Lua.org, PUC-RioLua Macro 2.3.0 Copyright (C) 2007-2011 Steve Donovan> f = \x(x+1)> = f(2)3LM defines a short function form based on a suggestion by lhf (a lexical macro system isn't clever enough to do |x|...)Or even use a full-blown Lua-based language like MoonScript, which is particularly friendly for interactive work because the call operator has a very low precedence$ mooniMoonScript version 0.2.3Note: use backslash at line end to start a block> f = (x) -> x+1> f 23mooni is an experimental interactive version [2]. Sometimes problems make more sense with a more appropriate notation!steve d.[2] 'luarocks --from=http://rocks.moonscript.org install mooni'. If you don't have Git, then first grab moonscript using regular luarocks server.