5.1. The Data and Control Flow Dictionary [CLHS-5.3]

5.1.1. Macro DEFCONSTANT
5.1.2. Macro EXT:FCASE
5.1.3. Function EXT:XOR
5.1.4. Function EQ
5.1.5. Function SYMBOL-FUNCTION
5.1.6. Macro SETF
5.1.7. Special Operator FUNCTION
5.1.8. Macro DEFINE-SYMBOL-MACRO
5.1.9. Macro LAMBDA
5.1.10. Macros DEFUN & DEFMACRO

Function FUNCTION-LAMBDA-EXPRESSIONThe name of a FFI:FOREIGN-FUNCTION is a string (the name of the underlying C function), not a lisp function name.

Macro DESTRUCTURING-BINDThis 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-SETQThese macros are implemented as special operators (as permitted by Section 3.1.2.1.2.2) and, as such, are rather efficient.

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

5.1.2. Macro EXT:FCASE

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.

5.1.3. Function EXT:XOR

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.

5.1.4. Function EQ

EQ compares CHARACTERs and FIXNUMs as EQL does. No unnecessary copies are made of CHARACTERs and NUMBERs. Nevertheless, one should use EQL as it is more portable across Common Lisp implementations.

(LET ((x y)) (EQ x x)) always returns T, regardless of y.

See also Equality of foreign values..

5.1.5. Function SYMBOL-FUNCTION

(SETF (SYMBOL-FUNCTION symbol) object) requires 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.

5.1.6. Macro 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-FLOATs to digits bits.
VALUES-LIST

(SETF (VALUES-LIST list) form) is equivalent to (VALUES-LIST (SETF list (MULTIPLE-VALUE-LIST form))).

Note

Note that this place is restricted: it can only be used in SETF, EXT:LETF, EXT:LETF*, not in other positions.

&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 form &OPTIONAL environment), and (EXT:GET-SETF-METHOD-MULTIPLE-VALUE form &OPTIONAL environment) receive as optional argument 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.

See also Section 30.11.2, “Macros EXT:LETF & EXT:LETF*.

5.1.7. Special Operator FUNCTION

(FUNCTION symbol) returns the local function definition established by FLET or LABELS, if it exists, otherwise the global function definition.

(SPECIAL-OPERATOR-P symbol) returns NIL or T. If it returns T, then (SYMBOL-FUNCTION symbol) returns the (useless) special operator handler.

5.1.8. Macro DEFINE-SYMBOL-MACRO

The macro DEFINE-SYMBOL-MACRO establishes SYMBOL-MACROs with global scope (as opposed to SYMBOL-MACROs 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, (EXT:SYMBOL-MACRO-EXPAND symbol) returns two values, 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.

5.1.9. Macro LAMBDA

Constant LAMBDA-LIST-KEYWORDS(&OPTIONAL &REST &KEY &ALLOW-OTHER-KEYS &AUX &BODY &WHOLE &ENVIRONMENT)

Table 5.1. Function call limits


5.1.10. Macros DEFUN & DEFMACRO

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.41Last modified: 2006-10-13