Skip to content
TurtleKitty edited this page May 17, 2019 · 3 revisions

seal

This procedure wraps objects in an immutable seal.

The programmer can instruct seal to pass along messages with the pass: keyword.
and to hide other messages with the hide: keyword.
The secret: option allows the sealed object to be unsealed at a later time.

(def r (: x 1 y 2))
(def sr (seal r pass: '(x y)))
(def hr (seal r hide: '(set! del!)))
(def xr (seal r pass: '() secret: 'loki-sucks)) ; You know nothing about me!

(proc handler (e k) true)

sr.type              ; (sealed-object)
(list sr.x sr.y)     ; (1 2)
(hr.get 'x)          ; 1
(xr.get 'x)          ; (runtime-error (message-not-understood (send #(sealed-object ...) get) "Message not understood."))
(sr.unseal 'wrong)   ; (runtime-error (ACCESS-DENIED #(sealed-object ...) "ACCESS DENIED"))

(def free (xr.unseal 'loki-sucks))

(free.get 'x) ; 1
(free.get 'y) ; 2
Clone this wiki locally