Next: Introduction, Previous: (dir), Up: (dir) [Contents][Index]
This is the defenum Reference Manual, generated automatically by Declt version 3.0 "Montgomery Scott" on Mon Apr 19 15:52:33 2021 GMT+0.
• Introduction | What defenum 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 |
DEFENUM ======= Copyright (c) 2014-2021 Marco Antoniotti, all rights reserved. The DEFENUM facility provides C++ and Java styled 'enum' in Common Lisp. Please refer to the HTML documentation for more information. A NOTE ON FORKING ----------------- Of course you are free to fork the project subject to the current licensing scheme. However, before you do so, I ask you to consider plain old "cooperation" by asking me to become a developer. It helps keeping the entropy level at an acceptable level. Enjoy
Next: Files, Previous: Introduction, Up: Top [Contents][Index]
The main system appears first, followed by any subsystem dependency.
• The defenum system |
Marco Antoniotti
BSD
The DEFENUM facility provides C++ and Java styled ’enum’ in Common Lisp.
defenum.asd (file)
Files are sorted by type and then listed depth-first from the systems components trees.
• Lisp files |
• The defenum.asd file | ||
• The defenum/defenum-package.lisp file | ||
• The defenum/lambda-list-parsing.lisp file | ||
• The defenum/defenum.lisp file |
Next: The defenum/defenum-package․lisp file, Previous: Lisp files, Up: Lisp files [Contents][Index]
defenum.asd
defenum (system)
Next: The defenum/lambda-list-parsing․lisp file, Previous: The defenum․asd file, Up: Lisp files [Contents][Index]
defenum (system)
defenum-package.lisp
it.unimib.disco.ma.common-lisp.extensions.data-and-control-flow.defenum
Next: The defenum/defenum․lisp file, Previous: The defenum/defenum-package․lisp file, Up: Lisp files [Contents][Index]
defenum-package.lisp (file)
defenum (system)
lambda-list-parsing.lisp
Previous: The defenum/lambda-list-parsing․lisp file, Up: Lisp files [Contents][Index]
defenum (system)
defenum.lisp
Next: Definitions, Previous: Files, Up: Top [Contents][Index]
Packages are listed by definition order.
• The it.unimib.disco.ma.common-lisp.extensions.data-and-control-flow.defenum package |
The package containing the DEFENUM reference implementation.
defenum-package.lisp (file)
common-lisp
Definitions are sorted by export status, category, package, and then by lexicographic order.
• Exported definitions | ||
• Internal definitions |
Next: Internal definitions, Previous: Definitions, Up: Definitions [Contents][Index]
• Exported macros | ||
• Exported functions | ||
• Exported structures |
Next: Exported functions, Previous: Exported definitions, Up: Exported definitions [Contents][Index]
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
defenum.lisp (file)
Next: Exported structures, Previous: Exported macros, Up: Exported definitions [Contents][Index]
it.unimib.disco.ma.common-lisp.extensions.data-and-control-flow.defenum
defenum.lisp (file)
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.
it.unimib.disco.ma.common-lisp.extensions.data-and-control-flow.defenum
defenum.lisp (file)
(setf find-enum) (function)
it.unimib.disco.ma.common-lisp.extensions.data-and-control-flow.defenum
defenum.lisp (file)
find-enum (function)
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.
it.unimib.disco.ma.common-lisp.extensions.data-and-control-flow.defenum
defenum.lisp (file)
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.
it.unimib.disco.ma.common-lisp.extensions.data-and-control-flow.defenum
defenum.lisp (file)
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.
it.unimib.disco.ma.common-lisp.extensions.data-and-control-flow.defenum
defenum.lisp (file)
it.unimib.disco.ma.common-lisp.extensions.data-and-control-flow.defenum
defenum.lisp (file)
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.
it.unimib.disco.ma.common-lisp.extensions.data-and-control-flow.defenum
defenum.lisp (file)
Checks whether the argument is a valid tag for an enum.
it.unimib.disco.ma.common-lisp.extensions.data-and-control-flow.defenum
defenum.lisp (file)
Returns the tags of an enum.
it.unimib.disco.ma.common-lisp.extensions.data-and-control-flow.defenum
defenum.lisp (file)
Previous: Exported functions, Up: Exported definitions [Contents][Index]
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
defenum.lisp (file)
structure-object (structure)
print-object (method)
symbol
enum-name (function)
(setf enum-name) (function)
list
enum-tags (function)
(setf enum-tags) (function)
list
enum-constructor-arguments (function)
(setf enum-constructor-arguments) (function)
fixnum
0
enum-length (function)
(setf enum-length) (function)
(make-hash-table :test (function eql))
enum-id-map (function)
(setf enum-id-map) (function)
Previous: Exported definitions, Up: Definitions [Contents][Index]
• Internal special variables | ||
• Internal functions | ||
• Internal generic functions | ||
• Internal structures | ||
• Internal types |
Next: Internal functions, Previous: Internal definitions, Up: Internal definitions [Contents][Index]
The ’enum namespace’.
it.unimib.disco.ma.common-lisp.extensions.data-and-control-flow.defenum
defenum.lisp (file)
Next: Internal generic functions, Previous: Internal special variables, Up: Internal definitions [Contents][Index]
it.unimib.disco.ma.common-lisp.extensions.data-and-control-flow.defenum
defenum.lisp (file)
it.unimib.disco.ma.common-lisp.extensions.data-and-control-flow.defenum
defenum.lisp (file)
it.unimib.disco.ma.common-lisp.extensions.data-and-control-flow.defenum
defenum.lisp (file)
it.unimib.disco.ma.common-lisp.extensions.data-and-control-flow.defenum
defenum.lisp (file)
it.unimib.disco.ma.common-lisp.extensions.data-and-control-flow.defenum
defenum.lisp (file)
it.unimib.disco.ma.common-lisp.extensions.data-and-control-flow.defenum
defenum.lisp (file)
it.unimib.disco.ma.common-lisp.extensions.data-and-control-flow.defenum
defenum.lisp (file)
it.unimib.disco.ma.common-lisp.extensions.data-and-control-flow.defenum
defenum.lisp (file)
it.unimib.disco.ma.common-lisp.extensions.data-and-control-flow.defenum
defenum.lisp (file)
it.unimib.disco.ma.common-lisp.extensions.data-and-control-flow.defenum
defenum.lisp (file)
it.unimib.disco.ma.common-lisp.extensions.data-and-control-flow.defenum
defenum.lisp (file)
it.unimib.disco.ma.common-lisp.extensions.data-and-control-flow.defenum
defenum.lisp (file)
it.unimib.disco.ma.common-lisp.extensions.data-and-control-flow.defenum
defenum.lisp (file)
it.unimib.disco.ma.common-lisp.extensions.data-and-control-flow.defenum
defenum.lisp (file)
it.unimib.disco.ma.common-lisp.extensions.data-and-control-flow.defenum
defenum.lisp (file)
it.unimib.disco.ma.common-lisp.extensions.data-and-control-flow.defenum
defenum.lisp (file)
it.unimib.disco.ma.common-lisp.extensions.data-and-control-flow.defenum
defenum.lisp (file)
it.unimib.disco.ma.common-lisp.extensions.data-and-control-flow.defenum
defenum.lisp (file)
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
SYS:SRC;CODE;SEQ.LISP (not found)
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
SYS:SRC;CODE;SEQ.LISP (not found)
it.unimib.disco.ma.common-lisp.extensions.data-and-control-flow.defenum
defenum.lisp (file)
it.unimib.disco.ma.common-lisp.extensions.data-and-control-flow.defenum
defenum.lisp (file)
it.unimib.disco.ma.common-lisp.extensions.data-and-control-flow.defenum
defenum.lisp (file)
it.unimib.disco.ma.common-lisp.extensions.data-and-control-flow.defenum
defenum.lisp (file)
it.unimib.disco.ma.common-lisp.extensions.data-and-control-flow.defenum
defenum.lisp (file)
it.unimib.disco.ma.common-lisp.extensions.data-and-control-flow.defenum
defenum.lisp (file)
it.unimib.disco.ma.common-lisp.extensions.data-and-control-flow.defenum
defenum.lisp (file)
it.unimib.disco.ma.common-lisp.extensions.data-and-control-flow.defenum
defenum.lisp (file)
it.unimib.disco.ma.common-lisp.extensions.data-and-control-flow.defenum
defenum.lisp (file)
it.unimib.disco.ma.common-lisp.extensions.data-and-control-flow.defenum
defenum.lisp (file)
it.unimib.disco.ma.common-lisp.extensions.data-and-control-flow.defenum
defenum.lisp (file)
it.unimib.disco.ma.common-lisp.extensions.data-and-control-flow.defenum
defenum.lisp (file)
it.unimib.disco.ma.common-lisp.extensions.data-and-control-flow.defenum
defenum.lisp (file)
it.unimib.disco.ma.common-lisp.extensions.data-and-control-flow.defenum
defenum.lisp (file)
it.unimib.disco.ma.common-lisp.extensions.data-and-control-flow.defenum
defenum.lisp (file)
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
it.unimib.disco.ma.common-lisp.extensions.data-and-control-flow.defenum
defenum.lisp (file)
it.unimib.disco.ma.common-lisp.extensions.data-and-control-flow.defenum
defenum.lisp (file)
it.unimib.disco.ma.common-lisp.extensions.data-and-control-flow.defenum
defenum.lisp (file)
it.unimib.disco.ma.common-lisp.extensions.data-and-control-flow.defenum
defenum.lisp (file)
it.unimib.disco.ma.common-lisp.extensions.data-and-control-flow.defenum
defenum.lisp (file)
it.unimib.disco.ma.common-lisp.extensions.data-and-control-flow.defenum
defenum.lisp (file)
Next: Internal structures, Previous: Internal functions, Up: Internal definitions [Contents][Index]
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
lambda-list-parsing.lisp (file)
it.unimib.disco.ma.common-lisp.extensions.data-and-control-flow.defenum
lambda-list-parsing.lisp (file)
it.unimib.disco.ma.common-lisp.extensions.data-and-control-flow.defenum
lambda-list-parsing.lisp (file)
Next: Internal types, Previous: Internal generic functions, Up: Internal definitions [Contents][Index]
it.unimib.disco.ma.common-lisp.extensions.data-and-control-flow.defenum
lambda-list-parsing.lisp (file)
t_lambda-list (structure)
macro-lambda-list (structure)
ll-vars (method)
it.unimib.disco.ma.common-lisp.extensions.data-and-control-flow.defenum
lambda-list-parsing.lisp (file)
t_lambda-list (structure)
it.unimib.disco.ma.common-lisp.extensions.data-and-control-flow.defenum
lambda-list-parsing.lisp (file)
structure-object (structure)
lambda-list-var (structure)
ll-vars (method)
(or symbol it.unimib.disco.ma.common-lisp.extensions.data-and-control-flow.defenum::t_lambda-list list)
lli-item (function)
(setf lli-item) (function)
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)
lli-kind (function)
(setf lli-kind) (function)
(or symbol cons)
lli-form (function)
(setf lli-form) (function)
it.unimib.disco.ma.common-lisp.extensions.data-and-control-flow.defenum
lambda-list-parsing.lisp (file)
lambda-list-item (structure)
it.unimib.disco.ma.common-lisp.extensions.data-and-control-flow.defenum
lambda-list-parsing.lisp (file)
destructuring-lambda-list (structure)
ll-vars (method)
list
macro-lambda-list-whole-var (function)
(setf macro-lambda-list-whole-var) (function)
list
macro-lambda-list-env-var (function)
(setf macro-lambda-list-env-var) (function)
list
macro-lambda-list-body-var (function)
(setf macro-lambda-list-body-var) (function)
it.unimib.disco.ma.common-lisp.extensions.data-and-control-flow.defenum
lambda-list-parsing.lisp (file)
t_lambda-list (structure)
it.unimib.disco.ma.common-lisp.extensions.data-and-control-flow.defenum
lambda-list-parsing.lisp (file)
t_lambda-list (structure)
it.unimib.disco.ma.common-lisp.extensions.data-and-control-flow.defenum
lambda-list-parsing.lisp (file)
structure-object (structure)
list
ll-ordinary-vars (function)
(setf ll-ordinary-vars) (function)
list
ll-optional-vars (function)
(setf ll-optional-vars) (function)
list
ll-keyword-vars (function)
(setf ll-keyword-vars) (function)
list
ll-rest-var (function)
(setf ll-rest-var) (function)
list
ll-auxiliary-vars (function)
(setf ll-auxiliary-vars) (function)
boolean
ll-allow-other-keys (function)
(setf ll-allow-other-keys) (function)
it.unimib.disco.ma.common-lisp.extensions.data-and-control-flow.defenum
defenum.lisp (file)
structure-object (structure)
print-object (method)
symbol
%tag-enum (function)
(setf %tag-enum) (function)
symbol
%tag-name (function)
(setf %tag-name) (function)
Previous: Internal structures, Up: Internal definitions [Contents][Index]
it.unimib.disco.ma.common-lisp.extensions.data-and-control-flow.defenum
defenum.lisp (file)
it.unimib.disco.ma.common-lisp.extensions.data-and-control-flow.defenum
defenum.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: | D F L |
---|
Jump to: | D F L |
---|
Next: Variable index, Previous: Concept index, Up: Indexes [Contents][Index]
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 |
---|
Next: Data type index, Previous: Function index, Up: Indexes [Contents][Index]
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 |
---|
Previous: Variable index, Up: Indexes [Contents][Index]
Jump to: | D E G I L M O P S T |
---|
Jump to: | D E G I L M O P S T |
---|