Last active
October 3, 2016 04:45
-
-
Save paniq/c4e4e8198a5edaa9a9dcfac044fa1e7d 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
// so this is a typical implicit-continuation function | |
// as we know it from many languages: | |
function myfunc (f) { | |
f(2); | |
return 3; | |
} | |
// but this is how that function looks internally, | |
// with explicit control flow, invisible variables | |
// put in diamond brackets: | |
function myfunc (f, <return>) { | |
// we pass a continuation (effectively a callback) to f... | |
f(2, | |
function (x) { | |
// ...in which we call <return> to get out of it | |
<return>(3); | |
// if we had never called <return>, the program | |
// would have ended here, because the interpreter | |
// does not maintain a function stack. | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment