Created
January 15, 2012 00:02
-
-
Save isaacs/1613485 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// block-lambda proponents: what does this program do? | |
function omgnomakeitstopkillitwithfire (t) { | |
x = {|y| | |
return "returning: " + y | |
} | |
// now here comes a bunch of code. | |
// imagine there are 50 lines here | |
t(x) | |
// now a bunch more stuff. | |
// eventually: | |
x("there") | |
// then a bunch more stuff | |
// ending with: | |
return 100 | |
} | |
var ret = omgnomakeitstopkillitwithfire(function (cb) { | |
alert("before") | |
cb("here") | |
alert("after") | |
}) | |
alert(ret) | |
/** | |
* HOW DOES THIS NOT QUALIFY AS INSANE ACTION-AT-A-DISTANCE??? | |
* Seriously, this belongs in the bad-parts bucket with `with` and `eval`. | |
**/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@grncdr: stretch your imagination with some Smalltalk-80 code. There are plenty of uses for mixed local and non-local returns. See https://github.com/allenwb/ESnext-experiments/blob/master/ST80collections-exp0-blp.js for a start.
/be