markmahieu at googlemail.com
Mon Dec 28 09:12:02 PST 2009
On 28 Dec 2009, at 16:38, Neal Gafter wrote:
> One approach that could be used to have lambdas that are both transparent and allow early return would be to introduce some kind of labelling mechanism. The labelling mechanism could either be part of the lambda expression syntax or the block expression syntax. Then, introduce a labelled return statement, possibly something like this:
> return label : expression;
> I haven't found a way to do this that feels right, but it is an approach worth exploring.
Coincidentally I've just been pondering the same thing. I still think it's easier if there's a syntactic distinction between 'return'-ing from the enclosing method, and 'yield'-ing from the lambda; 'return' retains the same meaning it always had, and the difficulty is confined to the conceptual 'yield' statement which must cater for the lambda-specific complication of nested lambda expressions.
Making labelling a requirement to use 'yield' certainly seems too awkward, but perhaps defining a non-labelled yield as transferring control from the 'outermost' lambda (ie. transparent semantics for yield by default as well) would combine the desired preservation of semantics with 'nice' syntactic for the '9 out of 10' cases (because it's probably not even nested).
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the closures-dev