Created
March 27, 2020 08:37
-
-
Save Lovesan/18f3a5f7553531576c90de64adef2801 to your computer and use it in GitHub Desktop.
call/ec implemented in JS
This file contains 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
function call_ec(f) { | |
var tag = new EvalError('Continuation block no loger exists'); | |
try { | |
f(function(rv) { | |
tag.rv = rv; | |
throw tag; | |
}); | |
} catch(obj) { | |
if(obj === tag) { | |
return tag.rv; | |
} | |
throw obj; | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment