Search code examples
schemecontinuationsr6rs

Code a continuation that does nothing


Maybe my question has a really simple answer, but I cannot find it.

In Scheme R6RS how can I built a continuation that does nothing and requires any arguments?

My goal is to have a continuation, let's name it QUIT such that if I have the following code:

((lambda ()
  (display 1)
  (display 2)
  (QUIT)
  (displey "A")))

it preints 1 and 2 but not "A".+

Can you help me?

Thank you.


Solution

  • The most straightforward way is to use a simple "return" style continuation:

    (call/cc (lambda (return) 
        (display 1) 
        ...
        (return) 
        (display "A")))
    

    Does that help at all?