This section describes how to specify a CLIM presentation type. For a complete description of CLIM presentation types, options, and parameters, see 6.5, Predefined Presentation Types.
Several CLIM operators take presentation types as arguments. You specify them using a presentation type specifier.
Most presentation type specifiers are also Common Lisp type specifiers. For example, the boolean presentation type is a Common Lisp type specifier. Not all presentation types are Common Lisp types, and not all Common Lisp types are presentation types (e.g., hash-tables), but there is a lot of overlap (e.g., commands, numbers, and strings).
A presentation type specifier appears in one of the following three patterns:
The first pattern,
, indicates a simple presentation type, which can be one of the predefined presentation types or a user-defined presentation type. Examples of the first pattern are:
integer A predefined presentation type
pathname A predefined presentation type
boolean A predefined presentation type
student A user-defined presentation type
The second pattern,
, supports parameterized presentation types, which are analogous to parameterized Common Lisp types such as
(integer 0 9)
in method lambda lists. The function
uses the parameters to check object membership in a type. Adding parameters to a presentation type specifier produces a subtype that contains some but not necessarily all of the objects that are members of the unparameterized type. Thus the parameters can turn off the sensitivity of some presentations that would otherwise be sensitive. The parameters state a restriction on the presentation type, so a parameterized presentation type is a specialization or a subset of the unparameterized presentation type of that name.
Examples of the second pattern are:
(integer 0 10)
A parameterized type indicating an integer in the range of zero through ten.
A parameterized type indicating a string whose length is 25.
(member :yes :no :maybe)
A parameterized type that can be one of the three given values: :yes , :no , and :maybe .
The third pattern,
, enables you to specify options that affect the use or appearance of the presentation, but not its semantic meaning. The options are keyword/value pairs, and are defined by the presentation type. All presentation types accept the
option, which enables you to provide a string describing the presentation type. If provided, this option overrides the description specified in the
form, and also overrides the
For example, you can use this form to specify an octal integer from 0 to 10:
((integer 0 10) :base 8)
While in theory some presentation type options may appear as an option in any presentation type specifier, currently the only such option is :description .
Each presentation type has a name, which is usually a symbol naming the presentation type. The name can also be a CLOS class object (but not a built-in class object); this usage provides the support for anonymous CLOS classes.
Every presentation type is associated with a CLOS class. If
is a class object or the name of a class, and that class is not a built-in class, that class is used as the associated class. Otherwise,
defines a class with the metaclass
and superclasses determined by the presentation type definition. This class is not named
, since that could interfere with built-in Common Lisp types such as
of this class returns a list of the form
is a subclass of
Programmers are required to evaluate the defclass form first in the case when the same name is used in both a defclass and a define-presentation-type .
Every CLOS class (except for built-in classes) is a presentation type, as is its name. Unless it has been defined with define-presentation-type , it allows no parameters and no options.
Presentation type inheritance is used both to inherit methods ("what parser should be used for this type?"), and to establish the semantics for the type ("what objects are sensitive in this input context?"). Inheritance of methods is the same as in CLOS and thus depends only on the type name, not on the parameters and options.
During presentation method combination, presentation type inheritance arranges to translate the parameters of a subtype into a new set of parameters for its supertype, and translates the options of the subtype into a new set of options for the supertype.
Common Lisp Interface Manager 2.0 User's Guide - 7 Aug 2017