Me too. Had to throw the shorter one out to give it its due.
I will add strawman sections for these extensions to block_lamda_revival in a bit.
If the block-lambda takes no arguments, yes. But I'm thinking of CoffeeScript's do operator, which passes lexical references of the same name as the block-lambda's parameters: http://coffeescript.org/#try:list%20%3D%20[1%2C%202%2C%203]%0Afor%20x%20in%20list%0A%20%20do%20%28x%29%20-%3E%0A%20%20%20%20alert%20x list = [1, 2, 3] for x in list do (x) -> alert x which for example translates to: var list, x, _fn, _i, _len; list = [1, 2, 3]; _fn = function(x) { return alert(x); }; for (_i = 0, _len = list.length; _i < _len; _i++) { x = list[_i]; _fn(x); } Apologies for the CoffeeScript if it's not your thing, readers. Here's the block-lambda with do: version: let list = [1, 2, 3] for (let x of list) { do: { |x| alert x } } But of course, Harmony for-let-of and for-let-in loops provide a fresh binding per iteration, so this do: is not needed to capture each iteration's i value. Let's use old-style for: let x; for (x = 1; x < 4; x++) { do: { |x| alert x } } Here the single let x binding is prone to being captured with its final value, 4. The do: calls its block-lambda argument with each x value in turn, so (e.g.) the block-lambda can safely close over its parameter x and get each value in [1, 2, 3].
You're right, I was mis-remembering the return-to-label details.
Return-to-label has been fading for a while, it dates from an earlier lambda proposal era. I agree break/continue-with do the job. I'll talk to Allen about those a bit tomorrow.
I thought about new strawmen but still think it better to add do: and possibly break/continue-with to block-lambda revival to avoid too many little wiki pages. b/c-with, perhaps, deserve their own page but it's easy to split if necessary. Thanks for the offer to help, I may take you up on it yet. And thanks for the discussion. /be |
_______________________________________________ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss