Allen's lambda syntax proposal

Breton Slivka zen at
Fri Dec 5 22:51:05 PST 2008

On Sat, Dec 6, 2008 at 9:57 AM, Michael Day <mikeday at> wrote:

> (1) Expression lambdas: lambdas whose body is an expression.
> var x = lambda(y, z) y + z
> Solves the problem with completion leakage, solves the nested
> return/break/continue issue. However, quite limited in usage, and makes it
> difficult to use lambdas to replace functions as they can't contain loop
> statements. (Hello, recursion! :)

This idea appeals to me for a couple reasons:

1) I have occassionally found myself using and repeating fairly
complex expressions in the conditions of if statements. Functions
would work, but I tend to avoid them out of a (possibly misplaced?)
Perception that refactoring the expressions isn't quite worth the
performance cost of an extra function call. This is bad code practice
I will admit, but if there were something that didn't have quite the
performance cost, and could promote DRYness in expressions, that would
be great.

2) It would be really nice to have a callable value that was
garaunteed not to have side effects. a lambda with an expression body
might not be that. Nevertheless, this would enable a parallelized
array "map" function that's safe to use. In the absence of "real"
multithreading, this kind of parallelism would be a boon for
applications like 3d games, or image processing.

2008/12/6 David-Sarah Hopwood <david.hopwood at>:

> To type λ, I usually have to cut-and-paste it from somewhere else,
> which is quite inconvenient. But more importantly, having a
> non-US-ASCII character in the basic syntax means that parsing is
> dependent on recognising character encoding accurately. In practice,
> that is very hit-and-miss, with files' encoding often being labelled
> or guessed incorrectly. Currently, the effects of this are restricted
> to programs that use non-US-ASCII characters in strings without
> escaping, and therefore only the files containing such programs have
> to be labelled accurately.
> (I wish it weren't so, and often the reason why it is so is inexcusably
> poor attention to standards by application writers, but we have to be
> realistic.)
> --
> David-Sarah Hopwood

I thought as such, fair enough. It was just naive and boundless
optimism that in 5-10 years time, this would cease to be an issue, but
this is magical thinking.

More information about the Es-discuss mailing list