Previous: Method Generators, Up: Generic Dispatch


12.6.3 Dispatch Tags

A dispatch tag is an object that represents the “type” of an object, for the purposes of generic dispatch. Every object has an associated dispatch tag. Built-in objects like pairs or booleans have predefined tags, while dynamically typed objects like records have tags that are created as needed.

— procedure: dispatch-tag object

Returns the dispatch tag for object.

          (dispatch-tag #f)        #[dispatch-tag 17 (boolean)]
          (dispatch-tag #t)        #[dispatch-tag 17 (boolean)]
          (dispatch-tag (list))    #[dispatch-tag 18 (null)]
          (dispatch-tag (list 3))  #[dispatch-tag 19 (pair list)]
— procedure: built-in-dispatch-tag name

Returns the built-in dispatch tag called name. Name must be a symbol that is the name of a known built-in dispatch tag.

          (built-in-dispatch-tag 'boolean)  #[dispatch-tag 17 (boolean)]
          (built-in-dispatch-tag 'null)     #[dispatch-tag 18 (null)]
          (built-in-dispatch-tag 'pair)     #[dispatch-tag 19 (pair list)]
          (built-in-dispatch-tag 'list)     #[dispatch-tag 19 (pair list)]
— procedure: built-in-dispatch-tags

Returns a list of the built-in dispatch tags.

— procedure: record-type-dispatch-tag record-type

Returns the dispatch tag associate with record-type. See See Records, for more information about record types.

— procedure: dispatch-tag? object

Returns ‘#t’ if object is a dispatch tag, and ‘#f’ otherwise.

— procedure: guarantee-dispatch-tag object caller

Signals an error if object is not a dispatch tag. Caller is a symbol that is printed as part of the error message and is intended to be the name of the procedure where the error occurs.