; Rees's cell (These 3 values are primitive in Scheme 48.) (define (new-cell)(cons '() '())) (define cell-ref car) (define cell-set! set-car!) ;Rees's seal (verbatim from http://mumble.net/~jar/pubs/secureos/secureos.html) (define (new-seal) (let ((instances (new-cell))) (cell-set! instances '()) (let ((seal (lambda (rep) (let ((abs (new-cell))) (cell-set! instances (cons (cons abs rep) (cell-ref instances))) abs))) (unseal (lambda (abs) (let ((probe (assq abs (cell-ref instances)))) (if probe (cdr probe) (error "invalid argument" abs))))) (sealed? (lambda (x) (if (assq x (cell-ref instances)) #t #f)))) (list seal unseal sealed?)))) ; From Seal to Amplification ; By example. ; css is a counter source source. (css) => (cs . amp) where ; cs is a counter source and amp is an amplifier for just the ; yields of cs. ; Each invocation of a counter source returns an independent counter control. ; If cc is a counter control then (cc) returns the value in the cell ; and then increments the counter. ; if amp came with cs then (amp (cs)) is a counter reseter for the ; cell that (cs) controls. ; A resetter can set the counter to anything it wants. ; To return multiple values: (define (ylppa l p)(apply p l)) (define (css) (ylppa (new-seal)(lambda (seal unseal good?) (cons (lambda () (let ((cell (new-cell)))(cell-set! cell 0) (letrec ((me (lambda al (if (null? al) (let ((x (cell-ref cell)))(cell-set! cell (+ 1 x))x) (if (equal? al '("Who")) (seal (list me cell))))))) me))) (lambda (r)(ylppa (unseal (r "Who"))(lambda (id cell)(if (eq? r id) (lambda (nv)(cell-set! cell nv)))))))))) ; minimal test (define cp (css)) (define cs (car cp)) (define amp (cdr cp)) (define r1 (cs)) (define r2 (cs)) (define w1 (amp r1)) (w1 13) (r1) ; expect 13