lua-users home
lua-l archive

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


Luiz Henrique de Figueiredo <lhf@tecgraf.puc-rio.br> 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)
)

Denis
________________________________

la vita e estrany

http://spir.wikidot.com/