Next: , Previous: , Up: descriptors   [Contents][Index]


4.2 Core object–type descriptors

Core object–type descriptors gather the run–time characteristics of object–types like fixnums and strings; for every core object–type there is an already defined type descriptor, bound to a syntactic binding exported by the library (vicare system type-descriptors).

Such syntactic bindings have name derived from the type name by appending ‘-ctd’ (where ‘ctd’ stands for Core Type Descriptor). So the type name <fixnum> has the associated type descriptor <fixnum>-ctd, the type name <string> has the associated type descriptor <string>-ctd, et cetera.

Some usage examples:

(import (only (vicare system type-descriptors)
              <string>-ctd))

(type-descriptor <string>)         ⇒ <string>-ctd
(.name <string>-ctd)               ⇒ <string>
(.parent <string>-ctd)             ⇒ <top>-ctd

(.uids-list <string>-ctd)
⇒ (vicare:core-type:<string> vicare:core-type:<top>)

(let* ((retriever (.method-retriever <string>-ctd))
       (strlen    (retriever 'length)))
  (strlen "ciao"))
⇒ 4

The following syntactic bindings are exported by the library (vicare system type-descriptors).

Record Type: <core-type-descriptor>

The type name of objects describing core object–types. It has the following immutable fields:

name

A symbol representing the name of this type. For example: ‘<string>’.

parent

If this type has a parent: an instance of <core-type-descriptor> representing the parent of this type; otherwise #f.

type-predicate

#f or a function implementing the type predicate.

equality-predicate

#f or a function implementing the equality predicate.

comparison-procedure

#f or a function implementing the comparison procedure.

hash-function

#f or a function implementing the hash function.

uids-list

A list of symbols representing the hierarchy of unique identifiers (UIDs) for this type. The first item in the list is the UID of this type, then the parent’s UID, then the grandparent’s UID, et cetera.

method-retriever

If this type has methods: a procedure to be applied to the method name (a symbol) to retrieve the method implementation function; otherwise #f.

Function: core-type-descriptor? obj

Return #t if obj is an instance of <core-type-descriptor>; otherwise return #f.

Function: core-type-descriptor.name ctd
Function: core-type-descriptor.parent ctd
Function: core-type-descriptor.uids-list ctd
Function: core-type-descriptor.type-predicate ctd
Function: core-type-descriptor.equality-predicate ctd
Function: core-type-descriptor.comparison-procedure ctd
Function: core-type-descriptor.hash-function ctd
Function: core-type-descriptor.method-retriever ctd

Accessors for the fields of <core-type-descriptor>.

Function: core-type-descriptor.uid ctd

Return the UID of the core–type descriptor ctd.


Next: , Previous: , Up: descriptors   [Contents][Index]