There are 5 utilities.
- with-gensyms v1.0
-
Binds each variable named by a symbol in
names
to a unique symbol aroundforms
. Each ofnames
must either be either a symbol, or of the form:(symbol string-designator)
Bare symbols appearing in
names
are equivalent to:(symbol symbol)
The string-designator is used as the argument to
gensym
when constructing the unique symbol the named variable will be bound to.- Provides
with-gensyms
,with-unique-names
- Requires
- string-designator
- once-only v1.0
-
Evaluates
forms
with symbols specified inspecs
rebound to temporary variables, ensuring that each initform is evaluated only once.Each of
specs
must either be a symbol naming the variable to be rebound, or of the form:(symbol initform)
Bare symbols in
specs
are equivalent to(symbol symbol)
Example:
(defmacro cons1 (x) (once-only (x) `(cons ,x ,x))) (let ((y 0)) (cons1 (incf y))) => (1 . 1)
- Provides
once-only
- Requires
- make-gensym-list
- parse-body v1.0
-
Parses
body
into(values remaining-forms declarations doc-string)
. Documentation strings are recognized only ifdocumentation
is true. Syntax errors in body are signalled andwhole
is used in the signal arguments when given.- Provides
parse-body
- parse-ordinary-lambda-list v1.0
-
Parses an ordinary lambda-list, returning as multiple values:
Required parameters.
Optional parameter specifications, normalized into form:
(name init suppliedp)
Name of the rest parameter, or
nil
.Keyword parameter specifications, normalized into form:
((keyword-name name) init suppliedp)
Boolean indicating
&allow-other-keys
presence.&aux
parameter specifications, normalized into form
(name init)
.- Existence of
&key
in thelambda-list
.
Signals a
program-error
iflambda-list
is malformed.- Provides
parse-ordinary-lambda-list
- Requires
- simple-program-error, ensure-list, make-keyword
- destructuring-case v1.0
-
destructuring-case
, 'destructuring-ccaseand 'destructuring-ecase
are a combination ofcase
anddestructuring-bind
.keyform
must evaluate to afcons
.Clauses are of the form:
((case-keys . destructuring-lambda-list) form*)
The clause whose
case-keys
matchescar
ofkey
, as if bycase
,ccase
, orecase
, is selected, andform
s are then executed withcdr
ofkey
is destructured and Bound By Thedestructuring-lambda-list
.Example:
(defun dcase (x) (destructuring-case x ((:foo a b) (format nil "foo: ~S, ~S" a b)) ((:bar &key a b) (format nil "bar, ~S, ~S" a b)) (((:alt1 :alt2) a) (format nil "alt: ~S" a)) ((t &rest rest) (format nil "unknown: ~S" rest)))) (dcase (list :foo 1 2)) ; => "foo: 1, 2" (dcase (list :bar :a 1 :b 2)) ; => "bar: 1, 2" (dcase (list :alt1 1)) ; => "alt: 1" (dcase (list :alt2 2)) ; => "alt: 2" (dcase (list :quux 1 2 3)) ; => "unknown: 1, 2, 3" (defun decase (x) (destructuring-case x ((:foo a b) (format nil "foo: ~S, ~S" a b)) ((:bar &key a b) (format nil "bar, ~S, ~S" a b)) (((:alt1 :alt2) a) (format nil "alt: ~S" a)))) (decase (list :foo 1 2)) ; => "foo: 1, 2" (decase (list :bar :a 1 :b 2)) ; => "bar: 1, 2" (decase (list :alt1 1)) ; => "alt: 1" (decase (list :alt2 2)) ; => "alt: 2" (decase (list :quux 1 2 3)) ; =| error
- Provides
destructuring-case
,destructuring-ccase
,destructuring-ecase
- Requires
- once-only