[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: !



;; This is how we would write the "set!-free" make-cell in Scheme
;; extended with the F-operator and prompts (see Felleisen POPL88).

(define (make-cell)
  (# (rec state
       (F (lambda (set-state)
	    (lambda (op)
	      (case op
		[(get) state]
		[(set) set-state])))))))

;; Now with just F

(define (make-cell)
  (F (lambda (return-cell)
       (rec state
	 (F (lambda (set-state)
	      (return-cell
	       (lambda (op)
		 (case op
		   [(get) state]
		   [(set) set-state])))))))))

;; Of course what this code shows is that in a language with call/cc or F
;; either rec and letrec must be considered side-effects, or they must
;; be fixed so that it is not possible to find out that they are
;; implemented with side-effects.

;; Bruce Duba and Matthias Felleisen