11 Encapsulations
An encapsulation is an object that refers to another object, called its content. The Kernel data type encapsulation is encapsulated. Two encapsulations are equal?
iff they are eq?
. Encapsulations are immutable.
— Applicative: make-encapsulation-type (make-encapsulation-type)
Returns a list of the form
(e p? d)
, wheree
,p
?, andd
are applicatives, as follows. Each call tomake-encapsulation-type
returns different applicativese
,p?
, andd
.
e
is an applicative that takes one argument, and returns a fresh encapsulation with the argument as content. Encapsulations returned on different occasions are noteq?
.p?
is a primitive type predicate, that takes zero or more arguments and returns true iff all of them are encapsulations generated bye
.d
is an applicative that takes one argument; if the argument is not an encapsulation generated bye
, an error is signaled, otherwise the content of the encapsulation is returned.That is, the predicate
p?
only recognizes, and the decapsulatord
only extracts the content of, encapsulations created by the encapsulatore
that was returned by the same call tomake-encapsulation-type
.