The narrowed-types Reference Manual

Next: , Previous: , Up: (dir)   [Contents][Index]

The narrowed-types Reference Manual

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.

Table of Contents


1 Introduction

narrowed-types

Type definitions narrowed with predicates

Description

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.

Example

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.

References

CLHS 4.2.3: Type Specifiers


2 Systems

The main system appears first, followed by any subsystem dependency.


Previous: , Up: Systems   [Contents][Index]

2.1 narrowed-types

Type definitions narrowed with predicates

Author

JP Cimalando

License

BSD

Version

0.1

Source

narrowed-types.asd.

Child Component

narrowed-types.lisp (file).


3 Files

Files are sorted by type and then listed depth-first from the systems components trees.


Previous: , Up: Files   [Contents][Index]

3.1 Lisp


3.1.1 narrowed-types/narrowed-types.asd

Source

narrowed-types.asd.

Parent Component

narrowed-types (system).

ASDF Systems

narrowed-types.


3.1.2 narrowed-types/narrowed-types.lisp

Source

narrowed-types.asd.

Parent Component

narrowed-types (system).

Packages

narrowed-types.

Public Interface

deftype-narrowed (macro).


4 Packages

Packages are listed by definition order.


Previous: , Up: Packages   [Contents][Index]

4.1 narrowed-types

Source

narrowed-types.lisp.

Use List

common-lisp.

Public Interface

deftype-narrowed (macro).


5 Definitions

Definitions are sorted by export status, category, package, and then by lexicographic order.


Previous: , Up: Definitions   [Contents][Index]

5.1 Public Interface


5.1.1 Macros

Macro: 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.

Package

narrowed-types.

Source

narrowed-types.lisp.


Appendix A Indexes


Next: , Previous: , Up: Indexes   [Contents][Index]

A.1 Concepts


Next: , Previous: , Up: Indexes   [Contents][Index]

A.2 Functions

Jump to:   D   M  
Index Entry  Section

D
deftype-narrowed: Public macros

M
Macro, deftype-narrowed: Public macros

Jump to:   D   M  

Next: , Previous: , Up: Indexes   [Contents][Index]

A.3 Variables