encapsulations.texi (1608B)
1 @c -*-texinfo-*- 2 @setfilename ../src/encapsulations 3 4 @node Encapsulations, Promises, Continuations, Top 5 @comment node-name, next, previous, up 6 7 @chapter Encapsulations 8 @cindex encapsulations 9 10 An encapsulation is an object that refers to another object, called 11 its content. The Kernel data type encapsulation is encapsulated. Two 12 encapsulations are @code{equal?} iff they are @code{eq?}. 13 Encapsulations are immutable. 14 15 @c TODO this is a little spartan... maybe add some more content 16 @deffn Applicative make-encapsulation-type (make-encapsulation-type) 17 Returns a list of the form @code{(e p? d)}, where @code{e}, 18 @code{p}?, and @code{d} are applicatives, as follows. Each call to 19 @code{make-encapsulation-type} returns different applicatives 20 @code{e}, @code{p?}, and @code{d}. 21 22 @itemize @bullet 23 @item 24 @code{e} is an applicative that takes one argument, and returns a 25 fresh encapsulation with the argument as content. Encapsulations 26 returned on different occasions are not @code{eq?}. 27 28 @item 29 @code{p?} is a primitive type predicate, that takes zero or more 30 arguments and returns true iff all of them are encapsulations 31 generated by @code{e}. 32 33 @item 34 @code{d} is an applicative that takes one argument; if the argument is 35 not an encapsulation generated by @code{e}, an error is signaled, 36 otherwise the content of the encapsulation is returned. 37 @end itemize 38 39 That is, the predicate @code{p?} only recognizes, and the decapsulator 40 @code{d} only extracts the content of, encapsulations created by the 41 encapsulator @code{e} that was returned by the same call to 42 @code{make-encapsulation-type}. 43 @end deffn