A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.gnu.org/software/emacs/manual/html_node/elisp/Type-Specifiers.html below:

Type Specifiers (GNU Emacs Lisp Reference Manual)

Next: Autoload Type, Previous: Type Descriptors, Up: Programming Types   [Contents][Index]

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 used for several purposes, including: documenting function interfaces through declarations (see The declare Form), specifying structure slot types (see Structures in Common Lisp Extensions for GNU Emacs Lisp), performing type checks with cl-the (see Declarations in Common Lisp Extensions for GNU Emacs Lisp), and aiding the native compiler (see Compilation of Lisp to Native Code) in optimizing code generation and inferring function signatures.

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 Type Hierarchy of Emacs Lisp Objects.

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-1 … type-n)

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

(and type-1 … type-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-1 … value-n)

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

(function (arg-1-type … arg-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 Features of Argument Lists).

The following type specifier represents 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:

The following represents the single value of 10:

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


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4