PasteRack.org
Paste # 31907
2015-07-30 07:56:58

Fork as a new paste.

Paste viewed 276 times.


Embed:

shift/reset confusion

  1. #lang racket
  2.  
  3. (require racket/control)
  4.  
  5. (list
  6.   ; call/cc returns 'foo
  7.   ; continuation not invoked
  8.   (begin (call/cc (lambda (cont) 'foo)) 'bar)
  9.  
  10.   ; continuation invoked
  11.   (begin (call/cc (lambda (cont) (cont 'foo))) 'bar)
  12.  
  13.  
  14.   (reset (shift cont (cont 'foo)) 'bar)
  15.  
  16.   (reset (shift cont 'foo) 'bar)
  17. )

=>

'(bar bar bar foo)