Next: Introduction, Previous: (dir), Up: (dir) [Contents][Index]
This is the narrowed-types Reference Manual, version 0.1, generated automatically by Declt version 3.0 "Montgomery Scott" on Tue Dec 22 14:29:27 2020 GMT+0.
• Introduction | What narrowed-types is all about | |
• Systems | The systems documentation | |
• Files | The files documentation | |
• Packages | The packages documentation | |
• Definitions | The symbols documentation | |
• Indexes | Concepts, functions, variables and data types |
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: Top [Contents][Index]
The main system appears first, followed by any subsystem dependency.
• The narrowed-types system |
JP Cimalando
BSD
Type definitions narrowed with predicates
0.1
narrowed-types.asd (file)
narrowed-types.lisp (file)
Files are sorted by type and then listed depth-first from the systems components trees.
• Lisp files |
• The narrowed-types.asd file | ||
• The narrowed-types/narrowed-types.lisp file |
Next: The narrowed-types/narrowed-types․lisp file, Previous: Lisp files, Up: Lisp files [Contents][Index]
narrowed-types.asd
narrowed-types (system)
Previous: The narrowed-types․asd file, Up: Lisp files [Contents][Index]
narrowed-types (system)
narrowed-types.lisp
deftype-narrowed (macro)
Next: Definitions, Previous: Files, Up: Top [Contents][Index]
Packages are listed by definition order.
• The narrowed-types package |
narrowed-types.lisp (file)
common-lisp
deftype-narrowed (macro)
Definitions are sorted by export status, category, package, and then by lexicographic order.
• Exported definitions |
Previous: Definitions, Up: Definitions [Contents][Index]
• Exported macros |
Previous: Exported definitions, Up: Exported definitions [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.
narrowed-types.lisp (file)
Previous: Definitions, Up: Top [Contents][Index]
• Concept index | ||
• Function index | ||
• Variable index | ||
• Data type index |
Next: Function index, Previous: Indexes, Up: Indexes [Contents][Index]
Jump to: | F L N |
---|
Jump to: | F L N |
---|
Next: Variable index, Previous: Concept index, Up: Indexes [Contents][Index]
Jump to: | D M |
---|
Index Entry | Section | ||
---|---|---|---|
| |||
D | |||
deftype-narrowed : | Exported macros | ||
| |||
M | |||
Macro, deftype-narrowed : | Exported macros | ||
|
Jump to: | D M |
---|
Next: Data type index, Previous: Function index, Up: Indexes [Contents][Index]
Previous: Variable index, Up: Indexes [Contents][Index]
Jump to: | N P S |
---|
Jump to: | N P S |
---|