; my version of Stiegler's box. ; http://cap-lore.com/CapTheory/Synergy/E.html (lambda () (let ((thePayload '()) (hasPayload #f)) (cons (lambda (payload) (lambda () (set! thePayload payload) (set! hasPayload #t))) (lambda (box) (set! hasPayload #f) (box) (if hasPayload (begin (set! hasPayload #f) thePayload) #f))))) ; Interesting alternative -- returns nullOb upon bad box. (lambda (nullOb) (let ((content nullOb)) (cons (lambda (Ob) (lambda () (set! content Ob))) (lambda (box) (set! content nullOb) (box) (let ((r content)) (set! content nullOb) r))))) ; Demo: (let* ((p ((fileVal "Seal"))) (seal (car p)) (unseal (cdr p)) (b2 (seal 42)) (b3 (seal 43))) (cons (unseal b2) (unseal b3))) ; => (42 . 43)