Next: , Previous: , Up: The language   [Contents][Index]

5.19 Datums

Datums are the mechanism by which Librep allows Lisp programs to define new data types, such that these types are completely distinct from the built-in data types (i.e. they match none of the standard type predicates).

They also provide encapsulation, in that the data objects they provide are completely opaque, unless a pre-defined value is known (which was specified when the object was created, and is typically known only by the object’s creator).

These functions are provided in

Function: make-datum value key

Create and return a new datum object. It has the value value associated with it, and has type key.

Function: datum-ref arg key

If arg has type key, then return the value associated with it. Otherwise, an error is signalled.

Function: datum-set arg key value

If arg has type key, then set the value associated with it to be value. Otherwise, an error is signalled.

Function: has-type-p arg key

Return true if arg has type key.

Function: define-datum-printer key printer

Associate the function printer with all datum objects of type key. When any such object is printed, printer is applied to two arguments, the datum and the stream to which it should be printed (see Output Streams).