This is the defenum Reference Manual, generated automatically by Declt version 4.0 beta 2 "William Riker" on Sun Dec 15 05:57:33 2024 GMT+0.
The main system appears first, followed by any subsystem dependency.
defenum
The DEFENUM facility provides C++ and Java styled ’enum’ in Common Lisp.
Marco Antoniotti
BSD
defenum-package.lisp
(file).
lambda-list-parsing.lisp
(file).
defenum.lisp
(file).
Files are sorted by type and then listed depth-first from the systems components trees.
defenum/defenum.asd
defenum/defenum-package.lisp
defenum/lambda-list-parsing.lisp
defenum/defenum.lisp
defenum/defenum-package.lisp
defenum
(system).
it.unimib.disco.ma.common-lisp.extensions.data-and-control-flow.defenum
.
defenum/lambda-list-parsing.lisp
defenum-package.lisp
(file).
defenum
(system).
copy-destructuring-lambda-list
(function).
copy-generic-function-lambda-list
(function).
copy-lambda-list-item
(function).
copy-lambda-list-var
(function).
copy-macro-lambda-list
(function).
copy-ordinary-lambda-list
(function).
copy-specialized-lambda-list
(function).
destructuring-lambda-list
(structure).
destructuring-lambda-list-allow-other-keys
(function).
destructuring-lambda-list-auxiliary-vars
(function).
destructuring-lambda-list-keyword-vars
(function).
destructuring-lambda-list-optional-vars
(function).
destructuring-lambda-list-ordinary-vars
(function).
destructuring-lambda-list-p
(function).
destructuring-lambda-list-rest-var
(function).
generic-function-lambda-list
(structure).
generic-function-lambda-list-allow-other-keys
(function).
generic-function-lambda-list-auxiliary-vars
(function).
generic-function-lambda-list-keyword-vars
(function).
generic-function-lambda-list-optional-vars
(function).
generic-function-lambda-list-ordinary-vars
(function).
generic-function-lambda-list-p
(function).
generic-function-lambda-list-rest-var
(function).
lambda-list-item
(structure).
lambda-list-item-p
(function).
lambda-list-type
(type).
lambda-list-var
(structure).
lambda-list-var-p
(function).
lambda-list-var-type
(type).
ll-allow-other-keys
(reader).
ll-auxiliary-vars
(reader).
ll-keyword-vars
(reader).
ll-optional-vars
(reader).
ll-ordinary-vars
(reader).
ll-recall
(generic function).
ll-rest-var
(reader).
ll-vars
(generic function).
lli-form
(reader).
lli-item
(reader).
lli-kind
(reader).
lli-name
(function).
llv-form
(function).
llv-item
(function).
llv-kind
(function).
llv-name
(function).
macro-lambda-list
(structure).
macro-lambda-list-allow-other-keys
(function).
macro-lambda-list-auxiliary-vars
(function).
macro-lambda-list-body-var
(reader).
macro-lambda-list-env-var
(reader).
macro-lambda-list-keyword-vars
(function).
macro-lambda-list-optional-vars
(function).
macro-lambda-list-ordinary-vars
(function).
macro-lambda-list-p
(function).
macro-lambda-list-rest-var
(function).
macro-lambda-list-whole-var
(reader).
make-destructuring-lambda-list
(function).
make-generic-function-lambda-list
(function).
make-macro-lambda-list
(function).
make-ordinary-lambda-list
(function).
make-specialized-lambda-list
(function).
mkllitem
(function).
mkllvar
(function).
ordinary-lambda-list
(structure).
ordinary-lambda-list-allow-other-keys
(function).
ordinary-lambda-list-auxiliary-vars
(function).
ordinary-lambda-list-keyword-vars
(function).
ordinary-lambda-list-optional-vars
(function).
ordinary-lambda-list-ordinary-vars
(function).
ordinary-lambda-list-p
(function).
ordinary-lambda-list-rest-var
(function).
parse-ll
(generic function).
pll
(function).
specialized-lambda-list
(structure).
specialized-lambda-list-allow-other-keys
(function).
specialized-lambda-list-auxiliary-vars
(function).
specialized-lambda-list-keyword-vars
(function).
specialized-lambda-list-optional-vars
(function).
specialized-lambda-list-ordinary-vars
(function).
specialized-lambda-list-p
(function).
specialized-lambda-list-rest-var
(function).
t_lambda-list
(structure).
t_lambda-list-p
(function).
defenum/defenum.lisp
defenum-package.lisp
(file).
lambda-list-parsing.lisp
(file).
defenum
(system).
defenum
(macro).
enum
(structure).
enum-name
(reader).
find-enum
(function).
(setf find-enum)
(function).
next-enum-tag
(function).
nth-enum-tag
(function).
previous-enum-tag
(function).
print-object
(method).
print-object
(method).
tag-name
(function).
tag-of
(function).
tag-p
(function).
tags
(function).
%tag-enum
(reader).
(setf %tag-enum)
(writer).
%tag-name
(reader).
%tag-p
(function).
*enums-namespace*
(special variable).
build-enum-defstruct
(function).
build-enum-deftype
(function).
build-enum-fixnum-method
(function).
build-enum-function
(function).
build-enum-initialization
(function).
build-enum-method
(function).
build-enum-method-body
(function).
build-enum-method-redispatch-body
(function).
build-enum-methods
(function).
build-enum-predicate
(function).
build-enum-tag-defstruct
(function).
build-enum-tag-method
(function).
build-enum-tag-methods
(function).
build-enum-tag-slot-readers
(function).
canonicalize-tags-specs
(function).
enum-constructor-arguments
(reader).
enum-designator
(type).
enum-id-map
(reader).
(setf enum-id-map)
(writer).
enum-length
(reader).
enum-p
(function).
enum-tags
(reader).
get-tag-from-id
(function).
(setf get-tag-from-id)
(function).
make-method-spec
(function).
make-tag-spec
(function).
method-spec-args
(function).
method-spec-body
(function).
method-spec-method-keyword
(function).
method-spec-name
(function).
method-spec-quals
(function).
new-symbol
(function).
parse-method-spec
(function).
tag
(structure).
tag-designator
(type).
tag-enum
(function).
tag-name-internal
(function).
tag-spec-args
(function).
tag-spec-id
(function).
tag-spec-methods
(function).
tag-spec-tag
(function).
Packages are listed by definition order.
it.unimib.disco.ma.common-lisp.extensions.data-and-control-flow.defenum
The package containing the DEFENUM reference implementation.
defenum
common-lisp.extensions.defenum
cl.ext.defenum
enum-types
common-lisp
.
defenum
(macro).
enum
(structure).
enum-name
(reader).
find-enum
(function).
(setf find-enum)
(function).
next-enum-tag
(function).
nth-enum-tag
(function).
previous-enum-tag
(function).
tag-name
(function).
tag-of
(function).
tag-p
(function).
tags
(function).
%tag-enum
(reader).
(setf %tag-enum)
(writer).
%tag-name
(reader).
%tag-p
(function).
*enums-namespace*
(special variable).
build-enum-defstruct
(function).
build-enum-deftype
(function).
build-enum-fixnum-method
(function).
build-enum-function
(function).
build-enum-initialization
(function).
build-enum-method
(function).
build-enum-method-body
(function).
build-enum-method-redispatch-body
(function).
build-enum-methods
(function).
build-enum-predicate
(function).
build-enum-tag-defstruct
(function).
build-enum-tag-method
(function).
build-enum-tag-methods
(function).
build-enum-tag-slot-readers
(function).
canonicalize-tags-specs
(function).
copy-destructuring-lambda-list
(function).
copy-generic-function-lambda-list
(function).
copy-lambda-list-item
(function).
copy-lambda-list-var
(function).
copy-macro-lambda-list
(function).
copy-method-spec
(function).
copy-ordinary-lambda-list
(function).
copy-specialized-lambda-list
(function).
copy-tag-spec
(function).
destructuring-lambda-list
(structure).
destructuring-lambda-list-allow-other-keys
(function).
destructuring-lambda-list-auxiliary-vars
(function).
destructuring-lambda-list-keyword-vars
(function).
destructuring-lambda-list-optional-vars
(function).
destructuring-lambda-list-ordinary-vars
(function).
destructuring-lambda-list-p
(function).
destructuring-lambda-list-rest-var
(function).
enum-constructor-arguments
(reader).
enum-designator
(type).
enum-id-map
(reader).
(setf enum-id-map)
(writer).
enum-length
(reader).
enum-p
(function).
enum-tags
(reader).
generic-function-lambda-list
(structure).
generic-function-lambda-list-allow-other-keys
(function).
generic-function-lambda-list-auxiliary-vars
(function).
generic-function-lambda-list-keyword-vars
(function).
generic-function-lambda-list-optional-vars
(function).
generic-function-lambda-list-ordinary-vars
(function).
generic-function-lambda-list-p
(function).
generic-function-lambda-list-rest-var
(function).
get-tag-from-id
(function).
(setf get-tag-from-id)
(function).
lambda-list-item
(structure).
lambda-list-item-p
(function).
lambda-list-type
(type).
lambda-list-var
(structure).
lambda-list-var-p
(function).
lambda-list-var-type
(type).
ll-allow-other-keys
(reader).
ll-auxiliary-vars
(reader).
ll-keyword-vars
(reader).
ll-optional-vars
(reader).
ll-ordinary-vars
(reader).
ll-recall
(generic function).
ll-rest-var
(reader).
ll-vars
(generic function).
lli-form
(reader).
lli-item
(reader).
lli-kind
(reader).
lli-name
(function).
llv-form
(function).
llv-item
(function).
llv-kind
(function).
llv-name
(function).
macro-lambda-list
(structure).
macro-lambda-list-allow-other-keys
(function).
macro-lambda-list-auxiliary-vars
(function).
macro-lambda-list-body-var
(reader).
macro-lambda-list-env-var
(reader).
macro-lambda-list-keyword-vars
(function).
macro-lambda-list-optional-vars
(function).
macro-lambda-list-ordinary-vars
(function).
macro-lambda-list-p
(function).
macro-lambda-list-rest-var
(function).
macro-lambda-list-whole-var
(reader).
make-destructuring-lambda-list
(function).
make-generic-function-lambda-list
(function).
make-macro-lambda-list
(function).
make-method-spec
(function).
make-ordinary-lambda-list
(function).
make-specialized-lambda-list
(function).
make-tag-spec
(function).
method-spec-args
(function).
method-spec-body
(function).
method-spec-method-keyword
(function).
method-spec-name
(function).
method-spec-quals
(function).
mkllitem
(function).
mkllvar
(function).
new-symbol
(function).
ordinary-lambda-list
(structure).
ordinary-lambda-list-allow-other-keys
(function).
ordinary-lambda-list-auxiliary-vars
(function).
ordinary-lambda-list-keyword-vars
(function).
ordinary-lambda-list-optional-vars
(function).
ordinary-lambda-list-ordinary-vars
(function).
ordinary-lambda-list-p
(function).
ordinary-lambda-list-rest-var
(function).
parse-ll
(generic function).
parse-method-spec
(function).
pll
(function).
specialized-lambda-list
(structure).
specialized-lambda-list-allow-other-keys
(function).
specialized-lambda-list-auxiliary-vars
(function).
specialized-lambda-list-keyword-vars
(function).
specialized-lambda-list-optional-vars
(function).
specialized-lambda-list-ordinary-vars
(function).
specialized-lambda-list-p
(function).
specialized-lambda-list-rest-var
(function).
t_lambda-list
(structure).
t_lambda-list-p
(function).
tag
(structure).
tag-designator
(type).
tag-enum
(function).
tag-name-internal
(function).
tag-spec-args
(function).
tag-spec-id
(function).
tag-spec-methods
(function).
tag-spec-tag
(function).
Definitions are sorted by export status, category, package, and then by lexicographic order.
The DEFENUM macro defines an extended enumerated type in the environment.
The extended enumerated types are called ’enums’ and are akin to
both C/C++ and Java (5.0 and later) enums. The main idea is to provide an
enumerated type with symbolic tags and auxiliary
functionality in order to make this concept available in Common Lisp.
The DEFENUM macro is the entry point to the enum type’s definition.
The syntax accommodates both simple and sophisticated cases.
NAME names the enum type and eventually also a
function that maps ’tags’ to their ’implementation’. Tags can be
’simple’, i.e., symbolic, or ’structured’, in which case they are
actually structure objects that are themselves the ’range’ of an
implicit ’map’ with symbols in the ’domain’.
TAGS-SPECS is a list of tag specifications (tag-spec). A tag-spec has
the following (Common Lisp) syntax:
<pre>
tag-spec ::= SYMBOL
| (SYMBOL)
| (SYMBOL N)
| (SYMBOL (&rest args) &rest tag-methods)
| (SYMBOL N (&rest args) &rest tag-methods)
</pre>
Each SYMBOL is the symbolic tag. N is an integer constant. The first
three forms are the ’simple’ case, which corresponds to the
traditional C/C++ case. The other two cases correspond to
the ’structured’ case. ’args’ is a list of arguments to be passed
to the structured tag constructor. ’tag-methods’ is a list of method
specs similar to the ’enum methods’ specified in OPTIONS-AND-METHODS (see below)
that will be EQL-specialized on the symbolic and associated fixnum
values; these method specifications admit a simplified lambda
argument list, which has an implicit first argument provided by DEFENUM.
SLOTS is a list of ’slot specifications’ like those in DEFSTRUCT.
Specifing any slot ensures that the implementation will generate a
number of specialized functions and methods that will be able to deal
with ’structured tags’. Each slot has a ’slot-name’ and is specified as
read-only. Each slot has a reader named NAME-slot-name; all slots are
automatically declared ’read only’.
OPTIONS-AND-METHODS is a list of ’options’ and ’enum methods’. The options
are lists with a keyword in first position. The only option
recognized at this time is :DOCUMENTATION, with a second argument a
(doc) string, which will be associated to the enum type. The ’enum
methods’ specifications have the following form:
<pre>
enum-meth-spec ::= (:method M-NAME QUAL* ARGS &BODY M-BODY)
</pre>
M-NAME is the method name, QUAL is a method qualifier (zero or more),
ARGS is a specialized lambda-list, whose first argument is treated
specially, and M-BODY is a normal method body. The first argument of
the lambda list is treated specially if it is specialized on T (cfr.,
not specialized) or it is specialized on the enum type NAME.
References to slot names in M-BODY are substituted with appropriate
calls to the slot reader functions.
Arguments and Values:
NAME : a SYMBOL.
TAG-SPECS : a list of ’enum tags’ specifications.
SLOTS : a list of ’slot specifications’.
OPTIONS-AND-METHODS : a list of ’options’ and (enum specific) ’methods’.
Examples:
cl-prompt> (defenum seasons (spring summer autumn winter))
#<ENUM SEASONS (SPRING SUMMER AUTUMN WINTER)>
cl-prompt> (seasons ’spring)
SPRING
cl-prompt> winter
3
cl-prompt> (seasons-p ’winter)
T
cl-prompt> (seasons winter) ; No quote.
WINTER
cl-prompt> (defenum operation
((PLUS () (:method evaluate (x y) (+ x y)))
(MINUS () (:method evaluate (x y) (- x y)))
(TIMES () (:method evaluate (x y) (* x y)))
(DIVIDE () (:method evaluate (x y) (/ x y)))
))
#<ENUM OPERATION (PLUS MINUS TIMES DIVIDE)>
cl-prompt> (typep ’divide ’operation)
T
cl-prompt> (evaluate times 2 pi)
6.283185307179586D0
cl-prompt> (evaluate ’plus 40 2)
42
cl-prompt> (defenum (colors (:initargs (r g b)))
((red (255 0 0))
(green (0 255 0))
(blue (0 0 255))
(white (255 255 255))
(black (0 0 0))
)
((r 0 :type (integer 0 255) :read-only t)
(g 0 :type (integer 0 255) :read-only t)
(b 0 :type (integer 0 255) :read-only t)
)
(:documentation "The Colors Enum."))
#<ENUM COLORS (RED GREEN BLUE WHITE BLACK)>
cl-prompt> (colors-r red)
255
cl-prompt> (colors-g white)
255
cl-prompt> (documentation ’colors ’type)
"The Colors Enum."
cl-prompt> (previous-enum-tag ’colors ’green)
#<COLORS TAG RED>
cl-prompt> (previous-enum-tag ’colors *)
NIL
Notes:
The DEFENUM macro is inspired by Java ’enum’ classes; it offers
all the facilities of the Java version, while also retaining the C/C++
’enum tags are integers’ feature.
The use of the DEFENUM enumeration types has some limitations, due, of
course, to Common Lisp’s slack typing and a few implementation choices.
The slot name references in the enum and tag methods are done via SYMBOL-MACROLET.
it.unimib.disco.ma.common-lisp.extensions.data-and-control-flow.defenum
.
name
.
Finds an enum with name NAME in the system.
FIND-ENUM behaves like FIND-CLASS. If ERRORP is true and no enum is
found in the system an error is signaled. ENVIRONMENT is present for
symmetry with FIND-CLASS and it is currently unused.
Arguments and Values:
NAME : a SYMBOL
ERRORP : a generalized boolean
ENVIRONMENT : an environment object (or NIL)
result : an ENUM instance or NIL.
Given a tag designator TAG, returns the ’next’ tag in the enum E or NIL.
Arguments and Values:
enum : an enum designator (either an ENUM object or a SYMBOL).
tag : a tag designator (either a TAG object or a SYMBOL) or a FIXNUM.
result : a tag designator or NIL.
Returns the N-th tag in enum ENUM.
Arguments and Values:
N : a FIXNUM
ENUM : an enum designator (either an ENUM object or a SYMBOL).
result1 : a tag designator.
result2 : whether a tag was actually found.
Given a tag designator TAG, returns the ’previous’ tag in the enum
E or NIL.
Arguments and Values:
enum : an enum designator (either an ENUM object or a SYMBOL). tag : a tag designator (either a TAG object or a SYMBOL) or a FIXNUM. result : a tag designator or NIL.
Returns the tag object designated by TAG in enum E.
Arguments and Values:
E : an enum designator (either an ENUM object or a SYMBOL).
TAG : a tag designator (either a TAG object or a SYMBOL) or a FIXNUM.
ERRORP : a boolean.
RESULT : a tag designator.
Checks whether the argument is a valid tag for an enum.
Returns the tags of an enum.
The (abstract) Enum Structure.
Every enum will be derived from this structure, which cannot be instantiated. All enums will be singletons and stored in an ’enum namespace’.
it.unimib.disco.ma.common-lisp.extensions.data-and-control-flow.defenum
.
structure-object
.
list
This slot is read-only.
common-lisp
.
fixnum
0
This slot is read-only.
(make-hash-table :test (function eql))
it.unimib.disco.ma.common-lisp.extensions.data-and-control-flow.defenum
.
enum
.
it.unimib.disco.ma.common-lisp.extensions.data-and-control-flow.defenum
.
name
.
Return a copy of SEQUENCE which is EQUAL to SEQUENCE but not EQ.
it.unimib.disco.ma.common-lisp.extensions.data-and-control-flow.defenum
.
copy-seq
.
Return a copy of SEQUENCE which is EQUAL to SEQUENCE but not EQ.
it.unimib.disco.ma.common-lisp.extensions.data-and-control-flow.defenum
.
copy-seq
.
it.unimib.disco.ma.common-lisp.extensions.data-and-control-flow.defenum
.
it.unimib.disco.ma.common-lisp.extensions.data-and-control-flow.defenum
.
it.unimib.disco.ma.common-lisp.extensions.data-and-control-flow.defenum
.
it.unimib.disco.ma.common-lisp.extensions.data-and-control-flow.defenum
.
tags
.
it.unimib.disco.ma.common-lisp.extensions.data-and-control-flow.defenum
.
it.unimib.disco.ma.common-lisp.extensions.data-and-control-flow.defenum
.
it.unimib.disco.ma.common-lisp.extensions.data-and-control-flow.defenum
.
it.unimib.disco.ma.common-lisp.extensions.data-and-control-flow.defenum
.
it.unimib.disco.ma.common-lisp.extensions.data-and-control-flow.defenum
.
it.unimib.disco.ma.common-lisp.extensions.data-and-control-flow.defenum
.
it.unimib.disco.ma.common-lisp.extensions.data-and-control-flow.defenum
.
form
.
it.unimib.disco.ma.common-lisp.extensions.data-and-control-flow.defenum
.
item
.
it.unimib.disco.ma.common-lisp.extensions.data-and-control-flow.defenum
.
kind
.
it.unimib.disco.ma.common-lisp.extensions.data-and-control-flow.defenum
.
it.unimib.disco.ma.common-lisp.extensions.data-and-control-flow.defenum
.
it.unimib.disco.ma.common-lisp.extensions.data-and-control-flow.defenum
.
Returns the enum type where the tag designator TD belongs.
If TD is not a tag in an enum and ERRORP is non-NIL, an error is
signaled. Otherwise NIL is returned.
Arguments and Values:
TD : a ’tag designator’
ERRORP : a generalized boolean (default NIL).
result : the ENUM object or NULL
Produces an ’actual’ argument list using the lambda list variables.
This function is useful in order to write code transformers. It
produces a proper argument list suitable for use with APPLY.
Examples:
cl-prompt> (ll-recall (parse-ll :ordinary
’(a b &optional (c 42) &key (baz 42) &aux (foo 123))))
(A B C :BAZ BAZ ())
cl-prompt> (ll-recall (parse-ll :ordinary
’(a b &rest more)))
(A B MORE)
cl-prompt> (ll-recall (parse-ll :ordinary
’(a b &rest keys &key (foo 42))))
(A B :FOO FOO KEYS)
it.unimib.disco.ma.common-lisp.extensions.data-and-control-flow.defenum
.
t_lambda-list
)) ¶it.unimib.disco.ma.common-lisp.extensions.data-and-control-flow.defenum
.
macro-lambda-list
)) ¶destructuring-lambda-list
)) ¶lambda-list-item
)) ¶t_lambda-list
)) ¶it.unimib.disco.ma.common-lisp.extensions.data-and-control-flow.defenum
.
(eql :macro)
) ll) ¶(eql :destructuring)
) ll) ¶(eql :generic-function)
) ll) ¶(eql :specialized)
) ll) ¶(eql :ordinary)
) ll) ¶it.unimib.disco.ma.common-lisp.extensions.data-and-control-flow.defenum
.
it.unimib.disco.ma.common-lisp.extensions.data-and-control-flow.defenum
.
it.unimib.disco.ma.common-lisp.extensions.data-and-control-flow.defenum
.
structure-object
.
(or symbol it.unimib.disco.ma.common-lisp.extensions.data-and-control-flow.defenum::t_lambda-list list)
This slot is read-only.
it.unimib.disco.ma.common-lisp.extensions.data-and-control-flow.defenum::lambda-list-var-type
(quote it.unimib.disco.ma.common-lisp.extensions.data-and-control-flow.defenum::&reqvar)
This slot is read-only.
it.unimib.disco.ma.common-lisp.extensions.data-and-control-flow.defenum
.
it.unimib.disco.ma.common-lisp.extensions.data-and-control-flow.defenum
.
list
This slot is read-only.
list
This slot is read-only.
list
This slot is read-only.
it.unimib.disco.ma.common-lisp.extensions.data-and-control-flow.defenum
.
it.unimib.disco.ma.common-lisp.extensions.data-and-control-flow.defenum
.
it.unimib.disco.ma.common-lisp.extensions.data-and-control-flow.defenum
.
structure-object
.
list
This slot is read-only.
list
This slot is read-only.
list
This slot is read-only.
list
This slot is read-only.
list
This slot is read-only.
boolean
This slot is read-only.
it.unimib.disco.ma.common-lisp.extensions.data-and-control-flow.defenum
.
structure-object
.
symbol
Jump to: | %
(
B C D E F G L M N O P S T |
---|
Jump to: | %
(
B C D E F G L M N O P S T |
---|
Jump to: | *
A B C E F I K L N O R S T W |
---|
Jump to: | *
A B C E F I K L N O R S T W |
---|
Jump to: | D E F G I L M O P S T |
---|
Jump to: | D E F G I L M O P S T |
---|