Function FUNCTION-LAMBDA-EXPRESSION
. The name
of a FFI:FOREIGN-FUNCTION
is a string
(the name of the underlying C function), not a lisp function name.
Macro DESTRUCTURING-BIND
. This macro does not perform full error checking.
Macros PROG1
, PROG2
, AND
,
OR
, PSETQ
, WHEN
, UNLESS
, COND
, CASE
, MULTIPLE-VALUE-LIST
,
MULTIPLE-VALUE-BIND
, MULTIPLE-VALUE-SETQ
. These macros are implemented as special operators (as permitted by
Section 3.1.2.1.2.2)
and, as such, are rather efficient.
DEFCONSTANT
The initial value is not evaluated at compile time,
just like with DEFVAR
and DEFPARAMETER
.
Use EVAL-WHEN
if you need the value at compile time.
It is an error if a DEFCONSTANT
variable is bound at the moment
the DEFCONSTANT
is executed, but DEFCONSTANT
does not check
this.
constant variables may not be bound dynamically or lexically.
This macro allows specifying the test for CASE
, e.g.,
(fcase string= (subseq foo 0 (position #\Space foo)) ("first" 1) (("second" "two") 2) (("true" "yes") t) (otherwise nil))
is the same as
(let ((var (subseq foo 0 (position #\Space foo)))) (cond ((string= var "first") 1) ((or (string= var "second") (string= var "two")) 2) ((or (string= var "true") (string= var "yes")) t) (t nil)))
If you use a built-in HASH-TABLE
test (see Section 18.1.3, “Function HASH-TABLE-TEST
”)
as the test (e.g., EQUAL
instead of STRING=
above, but not a test
defined using EXT:DEFINE-HASH-TABLE-TEST
), the compiler will be able to optimize
the EXT:FCASE
form better than the corresponding
COND
form.
This function checks that exactly one of its arguments is non-NIL
and, if this is the case, returns its value and index in the argument
list as multiple values, otherwise returns NIL
.
EQ
EQ
compares CHARACTER
s and FIXNUM
s as EQL
does.
No unnecessary copies are made of CHARACTER
s and NUMBER
s.
Nevertheless, one should use EQL
as it is more portable across Common Lisp
implementations.
(
always
returns LET
((x
y
)) (EQ
x
x
))T
, regardless of y
.
See also Equality of foreign values..
SYMBOL-FUNCTION
(
requires SETF
(SYMBOL-FUNCTION
symbol
) object
)object
to be either a function, a SYMBOL-FUNCTION
return
value, or a lambda expression. The lambda expression is thereby immediately
converted to a FUNCTION
.
SETF
Additional places:
FUNCALL
(SETF
(FUNCALL
#'symbol
...)
object
)
and
(SETF
(FUNCALL
'symbol
...) object
)
are equivalent to (SETF
(symbol
...) object
)
.
PROGN
(SETF
(PROGN
form
... place
)
object
)
LOCALLY
(SETF
(LOCALLY
declaration
...
form
... place
) object
)
IF
(SETF
(IF
condition
place1
place2
)
object
)
GET-DISPATCH-MACRO-CHARACTER
(SETF
(GET-DISPATCH-MACRO-CHARACTER
...)
...)
calls SET-DISPATCH-MACRO-CHARACTER
.
EXT:LONG-FLOAT-DIGITS
:(SETF
(EXT:LONG-FLOAT-DIGITS
) digits
)
sets the
default mantissa length of LONG-FLOAT
s to digits
bits.
VALUES-LIST
(
is equivalent to SETF
(VALUES-LIST
list
) form
)(
.VALUES-LIST
(SETF
list
(MULTIPLE-VALUE-LIST
form
)))
&KEY
markers in DEFSETF
lambda lists are supported, but the
corresponding keywords must appear literally in the program text.
(
,
GET-SETF-EXPANSION
form
&OPTIONAL
environment
)(EXT:GET-SETF-METHOD
, and
form
&OPTIONAL
environment
)(EXT:GET-SETF-METHOD-MULTIPLE-VALUE
receive as optional argument form
&OPTIONAL
environment
)environment
the environment
necessary for macro expansions. In DEFINE-SETF-EXPANDER
and EXT:DEFINE-SETF-METHOD
lambda lists, one can
specify &ENVIRONMENT
and a variable, which will be bound to the
environment. This environment should be passed to all calls of
GET-SETF-EXPANSION
, EXT:GET-SETF-METHOD
and
EXT:GET-SETF-METHOD-MULTIPLE-VALUE
. If this is
done, even local macros will be interpreted as places correctly.
Attempts to modify read-only data will SIGNAL
an ERROR
.
Program text and quoted constants loaded from files are considered
read-only data. This check is only performed for strings, not for
conses, other kinds of arrays, and user-defined data types.
FUNCTION
(
returns the local function
definition established by FUNCTION
symbol
)FLET
or LABELS
, if it exists, otherwise
the global function definition.
(
returns SPECIAL-OPERATOR-P
symbol
)NIL
or
T
. If it returns T
, then (
returns the (useless) special operator handler.SYMBOL-FUNCTION
symbol
)
DEFINE-SYMBOL-MACRO
The macro DEFINE-SYMBOL-MACRO
establishes SYMBOL-MACRO
s with
global scope (as opposed to SYMBOL-MACRO
s defined with
SYMBOL-MACROLET
, which have local scope):
(
.DEFINE-SYMBOL-MACRO
symbol
expansion
)
The function
EXT:SYMBOL-MACRO-EXPAND
tests for a SYMBOL-MACRO
: If symbol
is defined as a SYMBOL-MACRO
in the global environment, (
returns two
values, EXT:SYMBOL-MACRO-EXPAND
symbol
)T
and the expansion; otherwise it returns NIL
.
EXT:SYMBOL-MACRO-EXPAND
is a special case of MACROEXPAND-1
. MACROEXPAND-1
can also test whether a symbol is defined as a SYMBOL-MACRO
in lexical environments
other than the global environment.
Calling BOUNDP
on a symbol defined as a SYMBOL-MACRO
returns
T
.
Calling SYMBOL-VALUE
on a symbol defined as a SYMBOL-MACRO
returns the value of the expansion. Calling SET
on a symbol defined
as a SYMBOL-MACRO
calls SETF
on the expansion.
Calling MAKUNBOUND
on a symbol defined as a SYMBOL-MACRO
removes the SYMBOL-MACRO
definition.
LAMBDA
Constant LAMBDA-LIST-KEYWORDS
. (
&OPTIONAL
&REST
&KEY
&ALLOW-OTHER-KEYS
&AUX
&BODY
&WHOLE
&ENVIRONMENT
)
Table 5.1. Function call limits
CALL-ARGUMENTS-LIMIT | 212=4096 |
MULTIPLE-VALUES-LIMIT | 27=128 |
LAMBDA-PARAMETERS-LIMIT | 212=4096 |
DEFUN
and DEFMACRO
are allowed in non-toplevel positions. As
an example, consider the old ([CLtL1]) definition of GENSYM
:
(let ((gensym-prefix "G") (gensym-count 1)) (defun gensym (&optional (x nil s)) (when s (cond ((stringp x) (setq gensym-prefix x)) ((integerp x) (if (minusp x) (error "~S: index ~S is negative" 'gensym x) (setq gensym-count x))) (t (error "~S: argument ~S of wrong type" 'gensym x)))) (prog1 (make-symbol (concatenate 'string gensym-prefix (write-to-string gensym-count :base 10 :radix nil))) (incf gensym-count))))
Variable CUSTOM:*SUPPRESS-CHECK-REDEFINITION*
. When CUSTOM:*SUPPRESS-CHECK-REDEFINITION*
is NIL
,
CLISP issues a WARNING
when a function (macro, variable, class,
etc) is redefined in a different file than its original definition.
It is not a good idea to set this variable to T
.
Variable CUSTOM:*DEFUN-ACCEPT-SPECIALIZED-LAMBDA-LIST*
. When CUSTOM:*DEFUN-ACCEPT-SPECIALIZED-LAMBDA-LIST*
is
non-NIL
, DEFUN
accepts specialized lambda lists, converting type-parameter
associations to type declarations:
(defun f ((x list) (y integer)) ...)
is equivalent to
(defun f (x y) (declare (type list x) (type integer y)) ...)
This extension is disabled by -ansi
and by setting CUSTOM:*ANSI*
to T
,
but can be re-enabled by setting CUSTOM:*DEFUN-ACCEPT-SPECIALIZED-LAMBDA-LIST*
explicitly.
These notes document CLISP version 2.41 | Last modified: 2006-10-13 |