Block Lambdas: break and continue
Allen Wirfs-Brock
allen at wirfs-brock.com
Sat Jan 14 21:50:10 PST 2012
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. One mountain to climb at a time.
With block lambdas that support the return statement we already have escape continuations:
function callWithEscapeContinuation(blockWithOneArg) {
let escapeContinuation = {|value| return value};
return blockWithOneArg(escapeContinuation);
}
result = callWithEscapeContinuation( {|escape|
...
if (cond) escape();
...
};
...
I used the Smalltalk equivalent [:v| ^v] all over the place in the implementation of the Smalltalk resumption-based exception handling system. In fact, with block lambdas and try-finally (not no catch). I could replicate the full Smalltalk-style EHS in JavaScript. (Not to argue that resumable exceptions are really that good of an idea).
Allen
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20120114/9b9ce3da/attachment.html>
More information about the es-discuss
mailing list