Convert current-continuation schema call to Common Lisp?

I am converting Schema code to Common Lisp. I do not know Schemes. I know a little Common Lisp.

Here is the schema code:

(define (with-process-abortion thunk)
    (call-with-current-continuation
        (lambda (k)
            (fluid-let ((*abort-process* k))
                (thunk)))))

I read the Scheme function a bit call-with-current-continuation, but to be honest, I have no idea what this function does. My conversion to Common Lisp is very skeletal at the moment:

(defun with-process-abortion (thunk)
    ;; No idea how to implement
    )

This SO post says:

each occurrence of the / cc call can be replaced by the following equivalent:

(lambda (fk) (f (lambda (v k0) (kv)) k))

where k is the continuation that you want to save, and (lambda (v k0) (kv)) is the return procedure that restores this continuation (anything continuation k0 that is active when it is called is discarded).

, ? k?

+4
1

, Common Lisp call/cc , " ". , , , , Scheme call/cc , Common Lisp catch throw, .

(with-process-abortion thunk)

`(catch 'wpa #,thunk)

(*abort-process*) (throw 'wpa nil)

+5

All Articles