[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Short function definition syntax; thoughts on Lua (was Re: [ANN] GSL Shell new beta release...)
- From: spir <denis.spir@...>
- Date: Sat, 5 Dec 2009 10:12:23 +0100
Luiz Henrique de Figueiredo <firstname.lastname@example.org> dixit:
> Why 'lambda' when 'function' exists and works just as well?
Sure. Python did the error of calling anonymous func defs "lambda" (as stated later by Guido v. Rossum).
> And one possible syntax could be
> function (x,y,z)=x+y*z
> which is reminiscent of Fortran one-line function statements except that
> defines anonymous functions.
Too bad '→' (right arrow char) is not on usual keyboards ;-) I would love it (and '↔' would replace '=' in my dream language.).
> This syntax is even friendlier to token filters because you only need to
> convert '=' to 'return' but the real problem is of course how to detect
> the end of the expression so that 'end' can be added.
Can we consider simply wrapping the whole expression inside (...)?
function (x,y,z) (x+y*z)
This avoids the need for both '=' and an 'end' token.
(I guess "function(...)(...)..." is well a syntax error as of now?)
But would still find clearer to have a different keyword. The issue is that the idiom precisely defines something very to the common math. sense of "function" (esp. in that there is no real statement, even less several ones, and 'return' is implicit). Maybe "map", or "expression"? Or "formula"?
(I find the latter rather clear:
formula (x,y,z) (x+y*z)
la vita e estrany