transparent lambda

Neal Gafter neal at gafter.com
Sun Dec 27 12:28:51 PST 2009


Your block expression is syntactically ambiguous with an array initializer,
and probably also ambiguous with Coin's proposed collection literals.

The yield syntax does not look good to me.  I think it would be hard to
notice, scanning the code, that there is an early termination, and the
target of the early termination is also hard to notice.  Instead of writing
this
*
*
*#int(int,int) zeroesComeFirst = #(int x, int y) {*
*    if (x == y) return 0;*
*    if (x == 0) return -1;*
*    if (y == 0) return 1;*
*    return (x < y) ? -1 : 1; }*

one would write

*#int(int,int) zeroesComeFirst = #(int x, int y) {*
*     if (x == y) =0;*
*     if (x == 0) =-1;*
*     if (y == 0) =1;*
*     =(x < y) ? -1 : 1; }*

Worse, your proposal breaks transparency.  That is explained in detail in <
http://gafter.blogspot.com/2006/08/tennents-correspondence-principle-and.html>,
but to spell it out, one would like the specification for a lambda to be
defined such that taking a statement

*stmt*

and wrapping it in a lambda an then executing it

*(#() { stmt }).invoke();*

have the same meaning, no matter what the context.  However, under your
specification they do not.  Consider the code

*#() { =3; }*

this is a lambda expression that returns an integer (3).  Now take the
statement =3; and wrap it in a lambda, executing it immediately:

* #() { (#() { =3; }).invoke(); }*

This has changed the enclosing expression from a lambda that returns an
integer (3) into a lambda expression that returns no result.

Cheers,
Neal

On Sun, Dec 27, 2009 at 11:22 AM, Peter Levart <peter.levart at gmail.com>wrote:

> On Sunday 27 December 2009 19:54:49 Peter Levart wrote:
> > (see attached HTML)
> >
>
> Please disregard the attempted-to-be-in-line-HTML message posted
> previously, and rather navigate
> this link:
>
> http://docs.google.com/View?id=df7j62rs_42zrcz5g6
>
> I hope now the form is correct.
>
> But do read my 1st message (without the attachment) since it provides the
> context.
>
> Regards, Peter
>
>


More information about the lambda-dev mailing list