2.4.19 Type Specifiers

A type specifier is an expression that denotes a type. A type represents a set of possible values. Type specifiers can be classified into primitive types and compound types.

Type specifiers are in use for several purposes, including: documenting function interfaces through declaration (see declareフォーム), specifying structure slot values (see Structures in Common Lisp Extensions for GNU Emacs Lisp), type-checking through cl-the (see Declarations in Common Lisp Extensions for GNU Emacs Lisp), and others.

Primitive type specifiers

Primitive types specifiers are the basic types (i.e. not composed by other type specifiers).

Built-in primitive types (like integer, float, string etc.) are listed in Emacs Lispオブジェクトの型階層.

Compound type specifiers

Compound types serve the purpose of defining more complex or precise type specifications by combining or modifying simpler types.

List of compound type specifiers:

(or type-1type-n)

The or type specifier describes a type that satisfies at least one of the given types.

(and type-1type-n)

Similarly the and type specifier describes a type that satisfies all of the given types.

(not type)

The not type specifier defines any type except the specified one.

(member value-1value-n)

The member type specifier allows to specify a type that includes only the explicitly listed values.

(function (arg-1-typearg-n-type) return-type)

The function type specifier is used to describe the argument types and the return type of a function. Argument types can be interleaved with symbols &optional and &rest to match the function’s arguments (see 引数リストの機能).

The type specifier represent a function whose first parameter is of type symbol, the second optional parameter is of type float, and which returns an integer:

 (function (symbol &optional float) integer)
(integer lower-bound upper-bound)

The integer type specifier can also be used as a compound type specifier to define a subset of integer values by specifying a range. This allows to precisely control which integers are valid for a given type.

lower-bound is the minimum integer value in the range and upper-bound the maximum. You can use * instead of the lower or upper bound to indicate no limit.

The following represents all integers from -10 to 10:

(integer -10 10)

The following represents the single value of 10:

(integer 10 10)

The following represents all the integers from negative infinity to 10:

(integer * 10)

This page has generated for branch:work/emacs-30_69b16e5c63840479270d32f58daea923fe725b90, commit:5e3f74b56ff47b5bcef2526c70f53f749bbd45f6 to check Japanese translation.