Last active
August 29, 2015 14:21
-
-
Save nex3/aff038b27ac5c518f963 to your computer and use it in GitHub Desktop.
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
/// "call/cc" implemented in terms of eevee's "fuckit" operator. | |
/// | |
/// See https://twitter.com/eevee/status/599308342364778496. | |
callcc(fn(continuation(returnValue))) { | |
var completer = new Completer(); | |
scheduleMicrotask(() { | |
fn((returnValue) => completer.complete(returnValue)); | |
}); | |
return fuckit completer.future; | |
} | |
/// "fuckit" implemented in terms of "call/cc". | |
fuckit(Future future) { | |
return callcc((continuation) { | |
future.then((value) => continuation(value)); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment