When a continuation is called as a procedure, does some jump occur?
For example, I have seen two use cases of continuation:
Are the continuation created by
call/cc
and the continuation used for making a call to a function in CPS the same concept, and do both involve jump?When a continuation captured by a
call/cc
call is called, the program execution flow will jump to thecall/cc
call.When a function in CPS is called with a continuation, does similar jump also occur? (I am not sure)
For example,
(letrec ([f (lambda (x) (cons 'a x))] [g (lambda (x) (cons 'b (f x)))] [h (lambda (x) (g (cons 'c x)))]) (cons 'd (h '()))) (d b a c) can be written in CPS as (letrec ([f (lambda (x k) (k (cons 'a x)))] [g (lambda (x k) (f x (lambda (v) (k (cons 'b v)))))] [h (lambda (x k) (g (cons 'c x) k))]) (h '() (lambda (v) (cons 'd v))))
(lambda (v) (cons 'd v))
is a continuation passed toh
, then tog
andf
, before it is eventually called. But when it is called, is there any jump also occurring?