Local functions
Neal Gafter
neal at gafter.com
Tue Feb 9 18:19:09 PST 2010
On Tue, Feb 9, 2010 at 5:34 PM, Alex Buckley <Alex.Buckley at sun.com> wrote:
> Initial reaction: local functions are a step too far, even if they do have a
> straightforward translation to lambdas.
Which is why we removed them after v00. I was just wondering if there
was some deeper meaning in "first class functions".
> My concern about lambdas duplicating the functionality of anon.inner classes
> has led me to think about dropping statement lambdas, keeping expression
> lambdas, and then adding block expressions. (I am avoiding saying anything
> about 'this' in such circumstances.)
Wow. Sounds great to me. Then you don't have to specify the return
type when you write a lambda (it is just the expression's type).
You probably need a way to write a lambda with a "void" result (e.g.
introduce a meaning for "void" in an expression context).
If you go this way, you might consider adding a way to yield a result
early from a block expression. Or, alternately, you could take the
position that if the programmer's control flow is so complicated that
they "need" to use a "return" statement, then they probably ought to
use a method (perhaps in an anonymous inner class). That was where we
ended up, but I continued to look (without success) for a good way to
yield a result early.
More information about the lambda-dev
mailing list