Next: Introduction, Previous: (dir), Up: (dir) [Contents][Index]
This is the narrowed-types Reference Manual, version 0.1, generated automatically by Declt version 4.0 beta 2 "William Riker" on Wed Jun 15 05:24:08 2022 GMT+0.
Next: Systems, Previous: The narrowed-types Reference Manual, Up: The narrowed-types Reference Manual [Contents][Index]
Type definitions narrowed with predicates
This Common Lisp package provides a single macro which helps you define type specifiers for subsets, on the basis on an existing supertype and a condition expressed on the value.
DEFMACRO deftype-narrowed ((var type super-type) &body body)
DEFTYPE-NARROWED defines a type with name TYPE as well as a matching predicate TYPE-p.
The instances of the resulting type are the subset of instances of SUPER-TYPE which satisfy
a condition on VAR expressed by the BODY of the statement.
This simple example defines a type for the odd integers.
(deftype-narrowed (x odd-integer integer)
(oddp x))
Note: In the body of the example, the argument x to oddp is guaranteed to be an instance of the supertype integer.
The type odd-integer is usable in any context where a type specifier is expected. This includes standard forms such as typep, check-type, typecase, the, defstruct, defclass. You may not use it however to specialize a generic method.
(typecase x
(odd-integer :odd)
(integer :even)
(t :other))
For some more usage examples, see tests.
Next: Files, Previous: Introduction, Up: The narrowed-types Reference Manual [Contents][Index]
The main system appears first, followed by any subsystem dependency.
Type definitions narrowed with predicates
JP Cimalando
BSD
0.1
narrowed-types.lisp (file).
Next: Packages, Previous: Systems, Up: The narrowed-types Reference Manual [Contents][Index]
Files are sorted by type and then listed depth-first from the systems components trees.
Next: narrowed-types/narrowed-types.lisp, Previous: Lisp, Up: Lisp [Contents][Index]
narrowed-types (system).
Previous: narrowed-types/narrowed-types.asd, Up: Lisp [Contents][Index]
narrowed-types (system).
deftype-narrowed (macro).
Next: Definitions, Previous: Files, Up: The narrowed-types Reference Manual [Contents][Index]
Packages are listed by definition order.
Next: Indexes, Previous: Packages, Up: The narrowed-types Reference Manual [Contents][Index]
Definitions are sorted by export status, category, package, and then by lexicographic order.
Previous: Definitions, Up: Definitions [Contents][Index]
Previous: Public Interface, Up: Public Interface [Contents][Index]
DEFTYPE-NARROWED defines a type with name TYPE as well as a matching predicate TYPE-p. The instances of the resulting type are the subset of instances of SUPER-TYPE which satisfy a condition on VAR expressed by the BODY of the statement.
Previous: Definitions, Up: The narrowed-types Reference Manual [Contents][Index]
Jump to: | D M |
---|
Index Entry | Section | ||
---|---|---|---|
| |||
D | |||
deftype-narrowed : | Public macros | ||
| |||
M | |||
Macro, deftype-narrowed : | Public macros | ||
|
Jump to: | D M |
---|
Jump to: | F N P S |
---|
Jump to: | F N P S |
---|