Skip to content
Bill Hails edited this page Dec 6, 2023 · 12 revisions

The special function here takes a function of one argument and passes it the current continuation as a function so that calling the current continuation is equivalent to returning through here. An example may make this clearer:

fn test(k) { k(3) }

here(
    fn(k) {
        if (test(k)) {
            4
        } else {
            5
        }
    }
);

returns 3. The continuation is first class like any other function and can be passed to other functions, stored in variables, called later etc. The type of here is ((#a -> #b) -> #a) -> #a).

here is called call-with-current-continuation, or call/cc in other languages.

Clone this wiki locally