Block Lambdas: break and continue

Brendan Eich brendan at mozilla.org
Wed Jan 18 01:14:08 PST 2012


> Allen Wirfs-Brock <mailto:allen at wirfs-brock.com>
> January 17, 2012 7:56 PM
>
> On Jan 17, 2012, at 10:14 AM, Grant Husbands wrote:
>
>> Allen Wirfs-Brock wrote:
>>> do: arr.alternate ({|o| if (...) continue; if (...) break; ...}, {|o| if
>>> (...) continue; ...});
>>>
>>> I don't see how this can support the most likely intended semantics
>>
>> I think others might have better answers, but it seems that the
>> meaning of 'break' is to stop the whole statement, and the meaning of
>> 'continue' is to skip the inner block and hence return to
>> arr.alternate. I'm sorry for my woolly language, but it seems
>> relatively equivalent to a for loop, in which 'break' stops the whole
>> statement and 'continue' skips the inner block and hence returns to
>> the looping code.
>
> Yes, that was the intended meaning I was trying to express.  But what 
> I was illustrating was that for this to work a continue wihout a 
> target label and an equivalently located break without a target label 
> need to unwind to different points in the enclosing nesting structure. 
>  This seems different (perhaps surprisingly so) from equivalent 
> continue/breaks nested only within blocks and an /IterationStatement/. 
>  But that is the semantics that are need to fulfill my intent is this 
> particular case. Maybe this generalizes to all use reasonable cases, 
> but it something about it makes me feel a bit uncomfortable.

Agreed, so I'm checking my impulse to extend 
http://wiki.ecmascript.org/doku.php?id=strawman:block_lambda_revival and 
aiming at separated strawmen for do: and break/continue-with. Not sure 
at this point when I'll get to them, more discussion welcome.


>> Perhaps what I'm saying is that I think "do:" is a label for the whole
>> callexpression, covering all lambda-block parameters. As far as the
>> specification goes, a continue that 'hits' the block lambda may well
>> be best described as a local return.
>
> Yes, this seems about right. But can this behavior for break/continue 
> be explained in a way that doesn't  seems arbitrarily different from 
> break/continue in the context of /IterationStatements/ and regular 
> blocks.
>
> Perhaps we can describe a general transformation that converts an 
> /IterationStatement/ to/from an equivalent call to an iteration 
> function with block lambda arguments.

This reminds me of

https://mail.mozilla.org/pipermail/es-discuss/2008-October/007819.html

et seq.

/be
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20120118/b4ab0c60/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: postbox-contact.jpg
Type: image/jpeg
Size: 1287 bytes
Desc: not available
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20120118/b4ab0c60/attachment.jpg>


More information about the es-discuss mailing list