(_cpointer tag [ ptr-type scheme-to-c c-to-scheme]) → ctype tag : any/c ptr-type : ctype? = _pointer scheme-to-c : (any/c . -> . any/c) = values c-to-scheme : (any/c . -> . any/c) = values
(_cpointer/null tag [ ptr-type scheme-to-c c-to-scheme]) → ctype tag : any/c ptr-type : ctype? = _pointer scheme-to-c : (any/c . -> . any/c) = values c-to-scheme : (any/c . -> . any/c) = values
Although any value can be used as a tag, by convention the symbol form
of a type name—
Pointer tags are checked with cpointer-has-tag? and changed with cpointer-push-tag!, which means that other tags are preserved on an existing pointer value. Specifically, if a base ptr-type is given and is itself a _cpointer, then the new type will handle pointers that have the new tag in addition to ptr-type’s tag(s). When the tag is a pair, its first value is used for printing, so the most recently pushed tag which corresponds to the inheriting type is displayed.
(define-cpointer-type _id ptr-type-expr)
(define-cpointer-type _id ptr-type-expr scheme-to-c-expr c-to-scheme-expr)
The optional expressions produce optional arguments to _cpointer.
In addition to defining _id to a type generated by _cpointer, _id/null is bound to a type produced by _cpointer/null type. Finally, id? is defined as a predicate, and id-tag is defined as an accessor to obtain a tag. The tag is the symbol form of id.
The cpointer-push-tag! function pushes the given tag value on cptr’s tags. The main properties of this operation are: (a) pushing any tag will make later calls to cpointer-has-tag? succeed with this tag, and (b) the pushed tag will be used when printing the pointer (until a new value is pushed). Technically, pushing a tag will simply set it if there is no tag set, otherwise push it on an existing list or an existing value (treated as a single-element list).