One more syntax option allowing nice control abstraction
Neal Gafter
neal at gafter.com
Mon Jun 20 13:29:38 PDT 2011
On Mon, Jun 20, 2011 at 12:21 PM, Alexander Kochurov <
alexander.kochurov at maxifier.com> wrote:
> David Goodenough suggested to use 'lambda' keyword:
> "lambda()(5)
> lambda(){return 5;}
>
> lambda(int x,int y) { if (x>y) return x; else return y; }"
>
> Control abstraction may be introduced later in the following way:
>
Your suggestion doesn't actually provide for control abstraction because of
the binding of the "return" construct (not to mention break, continue,
non-final variables, etc).
To see if you've added language support sufficient to provide control
abstraction, you might try defining a method that accepts a boolean and two
blocks of code and acts as an "if-then-else" statement. It needn't be
pretty (after all, we already have an if statement in the language) but it
should have the correct behavior *without *the contents of the "then" and
"else" blocks being rewritten from the way they would appear in a
language-provided if-then-else statement.
See also <http://video.google.com/videoplay?docid=4051253555018153503#>, <
http://gafter.blogspot.com/2007/03/closures-for-organizing-your-code.html>,
<
http://gafter.blogspot.com/2006/08/tennents-correspondence-principle-and.html>,
<
http://gafter.blogspot.com/2006/09/failure-of-imagination-in-language_17.html
>.
Cheers,
Neal
More information about the lambda-dev
mailing list