[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Short function definition syntax; thoughts on Lua
- From: "Juris Kalnins" <juris@...>
- Date: Mon, 07 Dec 2009 10:03:10 +0200
2. Expression trees
If one wants to get really compact, then we could actually allow
function construction at compile time at least for single argument
functions. For example, $ isn't currently used as a token, so consider:
$ would be defined as function( x ) return x end
$ * $ would be defined as function( x ) return x * x end
$ + 1 would be defined as function( x ) return x + 1 end
etc
Nice idea, but Super hard to specify correctly. What is g(x + f($ * $ +
1)):
g(x + f(function (_) return _ end + function (_) return _ end))
g(x + f(function (_) return _ * _ end + 1))
g(x + f(function (_) return _ * _ + 1 end))
g(x + function (_) return f(_ * _ + 1) end)
g(function (_) return x + f(_ * _ + 1) end)
?
Plus, you have to make parser backtrack arbitrarily far upon encountering
'$'.
Currently it pretty much can emit bytecode as it goes over expression.
There was a nice proposal in another message,
Luiz Henrique de Figueiredo <lhf@tecgraf.puc-rio.br> wrote:
And one possible syntax could be
function (x,y,z)=x+y*z
function (x,y,z = x+y*z), which doesn't have issues with finding
expression end would be even nicer.
What would be nice to have, instead of arbitrary set of syntax extensions,
is some hooks into parser, that would allow to implement things like these,
or like the current shorthand notations as external C library.
- References:
- [ANN] GSL Shell new beta release with anti-gran graphics module, Francesco Abbate
- Re: [ANN] GSL Shell new beta release with anti-gran graphics module, steve donovan
- Re: [ANN] GSL Shell new beta release with anti-gran graphics module, David Kastrup
- Re: [ANN] GSL Shell new beta release with anti-gran graphics module, Norman Ramsey
- Re: [ANN] GSL Shell new beta release with anti-gran graphics module, David Kastrup
- Re: [ANN] GSL Shell new beta release with anti-gran graphics module, Norman Ramsey
- Short function definition syntax; thoughts on Lua (was Re: [ANN] GSL Shell new beta release...), Doug Rogers
- Re: Short function definition syntax; thoughts on Lua (was Re: [ANN] GSL Shell new beta release...), steve donovan
- Re: Short function definition syntax; thoughts on Lua (was Re: [ANN] GSL Shell new beta release...), Luiz Henrique de Figueiredo
- Re: Short function definition syntax; thoughts on Lua (was Re: [ANN] GSL Shell new beta release...), spir
- Re: Short function definition syntax; thoughts on Lua, David Kastrup
- Re: Short function definition syntax; thoughts on Lua, spir
- Re: Short function definition syntax; thoughts on Lua, Mark Hamburg