structure C = SMLofNJ.Cont;
val top_level = ref(C.isolate(fn (x:bottom) => ()));
let val x = C.callcc(fn k => (top_level := k; 0)) in x end;
fun abort(x:bottom) = C.throw (!top_level) x;
1+abort(3*2);
There is no problem with top level continuations in Scheme, for example.
Also, where can I get information about other SML/NJ features, such as the
function isolate from the signature COMPILE?
Thank you,
Yevgeniy Makarov
> What is TopLevelCallcc exception in SML/NJ? I get it when I try the
> following code:
>
> structure C = SMLofNJ.Cont;
>
> val top_level = ref(C.isolate(fn (x:bottom) => ()));
>
> let val x = C.callcc(fn k => (top_level := k; 0)) in x end;
>
> fun abort(x:bottom) = C.throw (!top_level) x;
>
> 1+abort(3*2);
>
> There is no problem with top level continuations in Scheme, for example.
This is to avoid paradoxical situations related to the management of
the global symbol table (the environment that represents the bindings
that are known at toplevel). Basically, if you "jump back" to an
earlier point in the toplevel loop, you would have to roll back the
bindings that have been established in between. Doing so, however, is
rather tricky. Getting the toplevel environment right was difficult
enough, so the necessary implementation effort was probably seen as
outweighing the benefits of a feature of questionable (at best)
practical interest.
> Also, where can I get information about other SML/NJ features, such as the
> function isolate from the signature COMPILE?
I already posted a reply to your earlier question on this.
Matthias