Skip to content

Instantly share code, notes, and snippets.

@nex3
Last active August 29, 2015 14:21
Show Gist options
  • Save nex3/aff038b27ac5c518f963 to your computer and use it in GitHub Desktop.
Save nex3/aff038b27ac5c518f963 to your computer and use it in GitHub Desktop.
/// "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