5.1. The Data and Control Flow Dictionary
Prev | Chapter 5. Data and Control Flow | Next

## 5.1. The Data and Control Flow Dictionary [sec_the_data__w_dictionary]

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.

### 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.

If the variable is already bound to a value which is not `EQL` to the new value, a `WARNING` is issued.

constant variables may not be bound dynamically or lexically.

See also Section 3.3.2, “Declaration `EXT:CONSTANT-NOTINLINE`”.

If you need to undo a `DEFCONSTANT` form, `PROCLAIM` the symbol `SPECIAL` (to turn the constant variable into a dynamic variable), and then `PROCLAIM` it `EXT:NOTSPECIAL` (to turn the dynamic variable into a lexical variable).

### 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 `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.

`(`LET` ((`x` `y`)) (`EQ` `x` `x`))` always returns `T` for any Lisp object `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-FLOAT`s 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.

An attempt to modify read-only data `SIGNAL`s 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 31.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-MACRO`s with global scope (as opposed to `SYMBOL-MACRO`s defined with `SYMBOL-MACROLET`, which have local scope).

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.

### 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

`CALL-ARGUMENTS-LIMIT` | 212=4096
`MULTIPLE-VALUES-LIMIT` | 27=128
`LAMBDA-PARAMETERS-LIMIT` | 212=4096

### 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))))

See also Section 3.2.2.2, “Minimal Compilation ”.

Function `EXT:ARGLIST`. Function `(`EXT:ARGLIST` `name`)` returns the lambda list of the function or macro that `name` names and `SIGNAL`s an `ERROR` if `name` is not `FBOUNDP`. It also `SIGNAL`s an `ERROR` when the macro lambda list is not available due to the compiler optimization settings (see Section 3.3.5, “Declaration `SPACE`”).

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.45 | Last modified: 2008-04-15

Enter your search termsSubmit search form
Webclisp.cons.orgclisp.podval.orgwww.lisp.org

Prev | Up | Next
Chapter 5. Data and Control Flow | Home | Chapter 6. Iteration