PasteRack.org
Paste # 19942
2015-07-30 07:57:53

Fork as a new paste.

Paste viewed 70 times.


Embed:

shift/reset confusion

#lang racket

(require racket/control)

(list 
  ; call/cc returns 'foo
  ; continuation not invoked
  (begin (call/cc (lambda (cont) 'foo)) 'bar)

  ; continuation invoked
  (begin (call/cc (lambda (cont) (cont 'foo))) 'bar)

  ; delimited continuation invoked
  (reset (shift cont (cont 'foo)) 'bar) 

  ; why does this eval to foo?
  (reset (shift cont 'foo) 'bar) 
)