Re: Block Lambdas: break and continue

2012-01-18 Thread Brendan Eich
Allen Wirfs-Brock 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

Re: Block Lambdas: break and continue

2012-01-18 Thread Herby Vojčík
Brendan Eich wrote: Herby Vojčík mailto:he...@mailbox.sk January 18, 2012 2:34 AM Brendan Eich wrote: 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

Re: Block Lambdas: break and continue

2012-01-17 Thread Brendan Eich
Grant Husbands January 16, 2012 5:33 PM Brendan Eich wrote: 2. Variation on empty label: support "do" as a reserved-identifier label do: arr.forEach {|o| if (...) break; ... } This seems like a sound way of doing it, indeed (I omitted your first one because I prefer

Re: Block Lambdas: break and continue

2012-01-17 Thread Axel Rauschmayer
To complete the Smalltalk homage we would want this [the label do:] in expressions, and we'd also want do: to take a block-lambda directly, in addition to a CallWithBlockArguments. Minor possibility of future-hostility: Should real keyword arguments ever make it to ECMAScript, labels such

Re: Block Lambdas: break and continue

2012-01-17 Thread Grant Husbands
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

Re: Block Lambdas: break and continue

2012-01-17 Thread Brendan Eich
Axel Rauschmayer January 17, 2012 1:04 AM Minor possibility of future-hostility: Should real keyword arguments ever make it to ECMAScript, labels such as "do:" seem an obvious choice. No, JS doesn't allow reserved identifiers to be used as parameter names in any case.

Re: Block Lambdas: break and continue

2012-01-17 Thread Brendan Eich
Grant Husbands January 17, 2012 10:14 AM I think others might have better answers, but it seems that themeaning of 'break' is to stop the whole statement, and the meaning of'continue' is to skip the inner block and hence return toarr.alternate That's what I was

Re: Block Lambdas: break and continue

2012-01-17 Thread Allen Wirfs-Brock
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

Re: Block Lambdas: break and continue

2012-01-16 Thread Axel Rauschmayer
However, block lambdas are often evaluated for a value and none of the current continue/break based solutions include a way to provide an explicit continuation value. Here is an idea for that: foo {|| exit: { ... if (...) break exit with early;

Re: Block Lambdas: break and continue

2012-01-16 Thread Brendan Eich
With completion values as In ES1-5, not even depending on http://wiki.ecmascript.org/doku.php?id=harmony:completion_reform, it might be enough to say: foo {|| exit: { ... if (...) { early; break exit; }

Re: Block Lambdas: break and continue

2012-01-16 Thread Allen Wirfs-Brock
On Jan 16, 2012, at 11:09 AM, Brendan Eich wrote: With completion values as In ES1-5, not even depending on http://wiki.ecmascript.org/doku.php?id=harmony:completion_reform, it might be enough to say: You're right, according to ES 5 semantics this does provide early as the value of the

Re: Block Lambdas: break and continue

2012-01-16 Thread Brendan Eich
Allen Wirfs-Brock January 16, 2012 11:32 AM On Jan 16, 2012, at 11:09 AM, Brendan Eich wrote: I have some angst about loss of a hunk of code running "break L" up against " with (E)\nS" where E is an _expression_ and S is a statement and the two came from a

Re: Block Lambdas: break and continue

2012-01-16 Thread Brendan Eich
Allen Wirfs-Brock January 16, 2012 9:53 AM On Jan 15, 2012, at 11:16 PM, Brendan Eich wrote: I'm not slamming the door, but I do not want to lumber block-lambdas with more complexity if the hard case is as rare as I contend. Anyway "neat" is not enough. We need an

Re: Block Lambdas: break and continue

2012-01-16 Thread David Herman
On Jan 15, 2012, at 11:32 PM, Axel Rauschmayer wrote: Could we call block lambdas just lambdas? The former seems a bit pleonastic. Block lambdas is a proposal that combines block-based syntax with lambda-based semantics. There have been other proposals in the past which provide lambda

Re: Block Lambdas: break and continue

2012-01-16 Thread David Herman
On Jan 16, 2012, at 11:09 AM, Brendan Eich wrote: With completion values as In ES1-5, not even depending on http://wiki.ecmascript.org/doku.php?id=harmony:completion_reform, it might be enough to say: foo {|| exit: { ... if (...) {

Re: Block Lambdas: break and continue

2012-01-16 Thread Grant Husbands
Brendan Eich wrote: 2. Variation on empty label: support do as a reserved-identifier label   do: arr.forEach {|o|     if (...) break;     ...   } This seems like a sound way of doing it, indeed (I omitted your first one because I prefer this one). It avoids the more egregious syntax

Re: Block Lambdas: break and continue

2012-01-15 Thread Herby Vojčík
, 2012 11:05 PM To: Herby Vojčík Cc: François REMY ; es-discuss@mozilla.org Subject: Re: Block Lambdas: break and continue Herby Vojčík January 14, 2012 1:46 PM === Brendan Eich wrote === This doesn't address Herby's TCP-violating wish for a non-return that completes the block-lambda's control flow

Re: Block Lambdas: break and continue

2012-01-15 Thread Grant Husbands
Brendan Eich wrote: More when I reply to Axel in a bit. I think there may have been a misunderstanding. My proposed solution amounts to syntactic sugar over the existing strawman and makes break/continue work intuitively with loopy block lambdas, and your reply to Axel appears to be against an

Re: Block Lambdas: break and continue

2012-01-15 Thread Herby Vojčík
@mozilla.org Subject: Re: Block Lambdas: break and continue Brendan Eich wrote: More when I reply to Axel in a bit. I think there may have been a misunderstanding. My proposed solution amounts to syntactic sugar over the existing strawman and makes break/continue work intuitively with loopy block

Re: Block Lambdas: break and continue

2012-01-15 Thread Herby Vojčík
: Block Lambdas: break and continue Hi, your 'for call {|| ...}' is great and simple solution for (unlabeled) break, but it is not so for continue. For either continue could have the redesigned meaning I sketched out in my last post, but then you need expression to specify; or you want the legacy

Re: Block Lambdas: break and continue

2012-01-15 Thread Grant Husbands
Herby Vojčík wrote: your 'for call {|| ...}' is great and simple solution for (unlabeled) break, but it is not so for continue. To clarify, it matches what continue currently does for other loops, which is what I was aiming for. However, I do agree that early completion with a value is

Re: Block Lambdas: break and continue

2012-01-15 Thread Brendan Eich
Grant Husbands January 15, 2012 3:51 AM Brendan Eich wrote: More when I reply to Axel in a bit. I think there may have been a misunderstanding. My proposed solution amounts to syntactic sugar over the existing strawman and makes break/continue work intuitively with loopy

Re: Block Lambdas: break and continue

2012-01-15 Thread Grant Husbands
Brendan Eich wrote: I don't see how your proposal can work without exceptions. You write that it is syntactic sugar. Ok, what is the desugaring? How does for arr.ForEach { |o| if (...) break; } translate into JS without a throw that the implementation of arr.forEach, which is not

Re: Block Lambdas: break and continue

2012-01-15 Thread Brendan Eich
Grant Husbands January 15, 2012 8:00 AM The above would desugar to:label1: arr.forEach { |o| if (...) break label1;}If it had continue instead of break, it would desugar to:arr.forEach { |o| label2: { if (...) break label2; }}It wouldn't need to be described as

Re: Block Lambdas: break and continue

2012-01-15 Thread Herby Vojčík
-Pôvodná správa- From: Brendan Eich Sent: Sunday, January 15, 2012 8:56 PM To: Grant Husbands Cc: es-discuss@mozilla.org Subject: Re: Block Lambdas: break and continue ... block-Other ideas? /be === I sent an expression-less continue and break elaboration today. at 11:something

Re: Block Lambdas: break and continue

2012-01-15 Thread Allen Wirfs-Brock
On Jan 15, 2012, at 11:56 AM, Brendan Eich wrote: Grant Husbands January 15, 2012 8:00 AM The above would desugar to:label1: arr.forEach { |o| if (...) break label1;}If it had continue instead of break, it would desugar to:arr.forEach { |o| label2: { if (...)

Re: Block Lambdas: break and continue

2012-01-15 Thread Brendan Eich
Allen Wirfs-Brock January 15, 2012 2:31 PM On Jan 15, 2012, at 11:56 AM, Brendan Eich wrote: Thanks for writing this down. You're right, I was wrong: a new for arr.forEach { |o| if (...) break; } special form would not require exception-reified break and

Re: Block Lambdas: break and continue

2012-01-15 Thread Brendan Eich
Herby Vojčík January 15, 2012 12:15 PM -Pôvodná správa- From: Brendan Eich Sent: Sunday, January 15, 2012 8:56 PM To: Grant Husbands Cc: es-discuss@mozilla.org Subject: Re: Block Lambdas: break and continue ... block-Other ideas? /be === I sent

Re: Block Lambdas: break and continue

2012-01-15 Thread Axel Rauschmayer
The main problem I would have with for as a prefix is semantic, not grammatical: I would always expect to loop over something iterable and not a loop implementation. My impression: Let’s wait until we have a more powerful collection library (which I assume would use block lambdas extensively).

Re: Block Lambdas: break and continue

2012-01-15 Thread Brendan Eich
Axel Rauschmayer January 15, 2012 11:32 PM The main problem I would have with "for" as a prefix is semantic, not grammatical: I would always expect to loop over something iterable and not a loop implementation. Yes, I agree with that and it's what I meant by head-less

Re: Block Lambdas: break and continue

2012-01-14 Thread Herby Vojčík
to use based on which is more intent revealing per each use. Herby -Pôvodná správa- From: Axel Rauschmayer Sent: Saturday, January 14, 2012 6:04 AM To: Brendan Eich Cc: es-discuss@mozilla.org Subject: Re: Block Lambdas: break and continue I think it’s a valid concern. The idea is: If I

Re: Block Lambdas: break and continue

2012-01-14 Thread Grant Husbands
I should have been clearer in my original message; I'll avoid mentioning Ruby directly, again, as it misdirects conversation. Though I have no strong opinion on block-lambdas in javascript, I will try to restate my original position, for clarity: Block lambdas, as currently described in the

Re: Block Lambdas: break and continue

2012-01-14 Thread Herby Vojčík
I realized 'break' semantics is in no way enforceable in lambda-block control structure, and each early return is in fact 'continue' (which may stop the loop or whatever depending on the value). Also, since in lambda-block, | character could be used to distinguish it from keyword-loop-continue.

Re: Block Lambdas: break and continue

2012-01-14 Thread David Herman
On Jan 13, 2012, at 9:04 PM, Axel Rauschmayer wrote: I think it’s a valid concern. The idea is: If I can implement my own loops (the nice-looking paren-free syntax feeds that illusion!) then I also want those loops to have break and continue. You could statically determine what construct,

Re: Block Lambdas: break and continue

2012-01-14 Thread Herby Vojčík
. Herby -Pôvodná správa- From: David Herman Sent: Saturday, January 14, 2012 6:12 PM To: Axel Rauschmayer Cc: Brendan Eich ; es-discuss@mozilla.org Subject: Re: Block Lambdas: break and continue On Jan 13, 2012, at 9:04 PM, Axel Rauschmayer wrote: I think it’s a valid concern. The idea

Re: Block Lambdas: break and continue

2012-01-14 Thread Allen Wirfs-Brock
On Jan 14, 2012, at 9:12 AM, David Herman wrote: On Jan 13, 2012, at 9:04 PM, Axel Rauschmayer wrote: I think it’s a valid concern. The idea is: If I can implement my own loops (the nice-looking paren-free syntax feeds that illusion!) then I also want those loops to have break and

Re: Block Lambdas: break and continue

2012-01-14 Thread Axel Rauschmayer
If I understand your suggestion, you're proposing that non-local break and continue should be exposed as standard exceptions, and then implementors of loop-like abstractions could choose to catch them. ... Did I understand your suggestion correctly? Yes. I was thinking about the BGGA

Re: Block Lambdas: break and continue

2012-01-14 Thread François REMY
- From: Herby Vojčík Sent: Saturday, January 14, 2012 7:42 PM To: David Herman ; Axel Rauschmayer Cc: Brendan Eich ; es-discuss@mozilla.org Subject: Re: Block Lambdas: break and continue === David Herman wrote === This *may* not violate TCP (I'm not quite sure), but I'm not enthusiastic about

Re: Block Lambdas: break and continue

2012-01-14 Thread Brendan Eich
dná správa- From: David Herman Sent: Saturday, January 14, 2012 6:12 PM To: Axel Rauschmayer Cc: Brendan Eich ; es-discuss@mozilla.org Subject: Re: Block Lambdas: break and continue On Jan 13, 2012, at 9:04 PM, Axel Rauschmayer wrote: If I understand your suggestion, you're proposing that non-lo

Re: Block Lambdas: break and continue

2012-01-14 Thread Axel Rauschmayer
Two possibilities (but I’m not entirely sure how much sense they make): - Use a keyword that enables custom break and continue (problem: for clashes with iterators): for mycollection.each({ | x | if (x === 0) break }) - Standardize a BreakException. Then breaking isn’t the loop’s

Re: Block Lambdas: break and continue

2012-01-14 Thread Brendan Eich
Brendan Eich January 14, 2012 1:24 PM Exception handling is seldom used in the large except to void the exception. And then only near or at a top-level event loop. Exception handling is the issue here, because of the proposal to add reifed break and continue as

Re: Block Lambdas: break and continue

2012-01-14 Thread Herby Vojčík
: Saturday, January 14, 2012 10:16 PM To: François REMY Cc: Herby Vojčík ; es-discuss@mozilla.org Subject: Re: Block Lambdas: break and continue François REMY January 14, 2012 1:01 PM If we want to avoid to break TCP, we can go with “throw break;” and “throw continue;”. This doesn't address

Re: Block Lambdas: break and continue

2012-01-14 Thread Brendan Eich
Herby Vojčík January 14, 2012 1:46 PM === Brendan Eich wrote === This doesn't address Herby's TCP-violating wish for a non-return that completes the block-lambda's control flow normally with a value (the message to which I was replying). But you're right that it

Re: Block Lambdas: break and continue

2012-01-14 Thread Brendan Eich
François REMY January 14, 2012 2:06 PM Yes, I did not say I was going to struggle about that functionnality. I just read some of the many threads of this mailing list and, when I encounter an idea that resonnate in my brain, I do my best to play the Devils’

Re: Block Lambdas: break and continue

2012-01-14 Thread Grant Husbands
Brendan Eich wrote: Exception handling is seldom used in the large except to void the exception. And then only near or at a top-level event loop. Exception handling is the issue here, because of the proposal to add reifed break and continue as thrown exceptions. How exception handling is

Re: Block Lambdas: break and continue

2012-01-14 Thread Brendan Eich
Axel Rauschmayer January 14, 2012 1:19 PM Two possibilities (but I’m not entirely sure how much sense they make):- Use a keyword that enables custom break and continue (problem: "for" clashes with iterators):for mycollection.each({ | x | if (x === 0) break })

Re: Block Lambdas: break and continue

2012-01-14 Thread Allen Wirfs-Brock
On Jan 14, 2012, at 6:46 PM, Brendan Eich wrote: Adding escape continuations is another case of warty + shiny ~~~ shiny promised land hope as the evolutionary game we have to play on the web. Still, I'm in favor of escape continuations but I do not want to bundle them with block-lambdas.

Re: Block Lambdas: break and continue

2012-01-14 Thread Brendan Eich
Allen Wirfs-Brock January 14, 2012 9:50 PM With block lambdas that support the return statement we already have escape continuations: Right you are, but simulating "early return" in a block-lambda requires the caller to pass down a {|v| return v} block -- a bit

Block Lambdas: break and continue

2012-01-13 Thread Grant Husbands
Block lambdas have been a hot topic, recently, but there's a point of significant divergence between Ruby (which appears to be the inspiration) and the proposed solution, in the handling of continue (called 'next', in Ruby) and 'break'. To whit: In Ruby, 'next' will end the current run

Re: Block Lambdas: break and continue

2012-01-13 Thread Brendan Eich
Grant Husbands January 13, 2012 7:29 PM Block lambdas have been a hot topic, recently, but there's a point of significant divergence between Ruby (which appears to be the inspiration) Not Ruby alone, and not in any chauvinist my-language-is-better sense. Smalltalk is

Re: Block Lambdas: break and continue

2012-01-13 Thread Axel Rauschmayer
I think it’s a valid concern. The idea is: If I can implement my own loops (the nice-looking paren-free syntax feeds that illusion!) then I also want those loops to have break and continue. You could statically determine what construct, say, a break applies to and either throw a BreakException (if