On Jan 15, 2012, at 11:56 AM, Brendan Eich wrote:
I really like this because it lexically connects the loop label (explicit or implicit) with those referenced by break/continue within the associated block lambda. This eliminates all the dynamic scoping issues we had been grappling with on this thread.
While "for" may or may not be the best keyword, but you seem to be reading additional implications into it here and below in the context of arr.forEach. This is a general constructor for labeling exit points from calls that take literal block lambdas as arguments. The "forEach" is just one of an indefinite number of function names that might be called with such a construct. Some of those, may have names that clash with the initial keyword, what it is.
I assume that the syntactic production we are de-sugaring is: IterationStatement :: for [no ( here] _expression_ ; The [no ( here] is to disambiguate from other for forms. If we used a new contextual keyword it would be IterationStatement :: EGloop [no LineTerminator here] _expression_ ; I don't see in either case, why you would have any paren-free problems as it is essentially just an _expression_ statement with a prefix keyword. In particular, there is no "loop head" and no "body". that is just an interpretation of the arguments for some specific use cases. In fact, the functional abstraction may not be a loop at all. Also, things like the following for firstCall({|| ... break ...}).secondCall({||...break...}).thirdCall {||...break...}; are possible. In these cases, the first and second breaks may be a bit unintuitive as they break out of the statement rather than the call that contains them.
I don't understand the conflict, but I agree we could do block lambdas while deferring extended break/continue semantics . But this does seem like a neat approach.
Even though these are not necessarily "loops", I think loop is still a plausible keyword. Or consider in as a prefix operator: in arr.forEach { |o| if (...) break; } or here: in arr.forEach { |o| elsewhere: while (true) { if (...) break here; else break elsewhere; } If you interpreted in as a prefix operator, then you could say: in (in (in firstCall({|| ... break ...})).secondCall({||...break...})).thirdCall {||...break...}; if you needed to. Note the outer in (the _expression_ statement) could be explicitly labelled but the inner ins could not.
I suspect that learning that loop does do what Doug suggested is less of a burden than leaning what {||...} means.
... if (...) break label; }); hate the extra ( ) needed to disambiguate other do usages. label: break {arr.forEach {|o| ... if (...) break label; }}; extra { } not much better label: with arr.forEach {|o| //no ( here after the with keyword ... if (...) break label; }; repurposed with keyword, scopes the label Allen
|
_______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss


