All Manuals > Common Lisp Interface Manager 2.0 User's Guide > Chapter 6 Presentation Types

NextPrevUpTopContentsIndex

6.2 How to Specify a CLIM Presentation Type

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:

name

( name parameters ...)

(( name parameters ...) options ...)

The first pattern, name , 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, ( name parameters ...) , supports parameterized presentation types, which are analogous to parameterized Common Lisp types such as (integer 0 9) in method lambda lists. The function presentation-typep 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.

(string 25) 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, (( name parameters ...) options ...) , 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 :description option, which enables you to provide a string describing the presentation type. If provided, this option overrides the description specified in the define-presentation-type form, and also overrides the describe-presentation-type presentation method.

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 name 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, define-presentation-type defines a class with the metaclass clim:presentation-type-class and superclasses determined by the presentation type definition. This class is not named name , since that could interfere with built-in Common Lisp types such as and , member , and integer . class-name of this class returns a list of the form (presentation-type name ) . clim:presentation-type-class is a subclass of standard-class .

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

NextPrevUpTopContentsIndex