All Manuals > Common Lisp Interface Manager 2.0 User's Guide > Chapter 7 Defining a New Presentation Type > 7.2 CLIM Operators for Defining New Presentation Types

NextPrevUpTopContentsIndex

7.2.2 CLIM Operators for Defining Presentation Type Abbreviations

You can define an abbreviation for a presentation type for the purpose of naming a commonly used cliche. The abbreviation is simply another name for a presentation type specifier.

Exported functions that call expand-presentation-type-abbreviation allow abbreviations.

accept

accept-from-string

with-output-as-presentation

with-input-context

present

describe-presentation-type

presentation-type-history

presentation-default-preprocessor

define-presentation translator

define-presentation-type-abbreviation[Macro]	

Arguments: name parameters equivalent-type &key options

Summary: Defines a presentation type that is an abbreviation for the presentation type specifier that is the value of equivalent-type.

Where presentation type abbreviations are allowed, equivalent-type and abbreviations are exactly equivalent and can be used interchangeably.

name must be a symbol and must not be the name of a CLOS class.

The equivalent-type form might be evaluated at compile time if presentation type abbreviations are expanded by compiler optimizers. Unlike inherit-from , equivalent-type can perform arbitrary computations and is not called with dummy parameter and option values. The type specifier produced by evaluating equivalent-type can be a real presentation type or another abbreviation. If the type specifier does not include the standard option :description , the option is automatically copied from the abbreviation to its expansion.

Note that you cannot define any presentation methods on a presentation type abbreviation. If you need methods, use define-presentation-type instead.

define-presentation-type-abbreviation is used to name a commonly used cliche. For example, a presentation type to read an octal integer might be defined as:

        (define-presentation-type-abbreviation octal-integer 
          (&optional low high)
          `((integer ,low ,high) :base 8 
            :description "octal integer")) 

None of the arguments, except equivalent-type , is evaluated.

When writing presentation type abbreviations, it is sometimes useful to let CLIM include or exclude defaults for parameters and options. In some cases, you may also find it necessary to "expand" a presentation type abbreviation. The following three functions are useful in these circumstances.

expand-presentation-type-abbreviation-1[Function]	

Arguments: type &optional environment

Summary: If the presentation type specifier type is a presentation type abbreviation, or is an and , or , sequence , or sequence-enumerated that contains a presentation type abbreviation, then expand-presentation-type-abbreviation-1 expands the type abbreviation once and returns two values, the expansion and t . If type is not a presentation type abbreviation, then the values type and nil are returned. env is a macro-expansion environment, as in macroexpand .

expand-presentation-type-abbreviation[Function]	

Arguments: type &optional environment

Summary: expand-presentation-type-abbreviation is like expand-presentation-type-abbreviation-1 , except that type is repeatedly expanded until all presentation type abbreviations have been removed.

make-presentation-type-specifier [Function]	

Arguments: type-name-and-parameters &rest options

Summary: A convenient way to make a presentation type specifier including only non-default options. This is only useful for abbreviation expanders, not for the :inherit-from clause of define-presentation-type . type-name-and-parameters is a presentation type specifier that must be in the form of:

( type-name parameters ...)

options is a list of alternating keywords and values that are added as options to the specifier. If a value is equal to type-name 's default, that option is omitted, producing a more concise presentation type specifier.


Common Lisp Interface Manager 2.0 User's Guide - 7 Aug 2017

NextPrevUpTopContentsIndex