[d48316]: impnotes / flow-dict.html Maximize Restore History

Download this file

flow-dict.html    132 lines (131 with data), 37.8 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>5.1. The Data and Control Flow Dictionary
[CLHS-5.3]</title><link rel="stylesheet" href="impnotes.css" type="text/css" /><link rev="made" href="mailto:clisp-list@lists.sourceforge.net" /><meta name="generator" content="DocBook XSL Stylesheets V2005-10-07_10:16_snapshot" /><link rel="start" href="index.html" title="Implementation Notes for GNU CLISP" /><link rel="up" href="data.html" title="Chapter 5. Data and Control Flow&#10; [CLHS-5]" /><link rel="prev" href="data.html" title="Chapter 5. Data and Control Flow&#10; [CLHS-5]" /><link rel="next" href="iteration.html" title="Chapter 6. Iteration&#10; [CLHS-6]" /></head><body><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">5.1. The Data and Control Flow Dictionary
[CLHS-5.3]</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="data.html">Prev</a> </td><th width="60%" align="center">Chapter 5. Data and Control Flow
[CLHS-5]</th><td width="20%" align="right"> <a accesskey="n" href="iteration.html">Next</a></td></tr></table><hr /></div><div class="section" lang="en" xml:lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="flow-dict"></a>5.1. The Data and Control Flow Dictionary
<a href="http://www.lisp.org/HyperSpec/Body/sec_the_data__w_dictionary.html" target="_top">[CLHS-5.3]</a></h2></div></div></div><div class="toc"><dl><dt><span class="section"><a href="flow-dict.html#defconstant">5.1.1. Macro <code class="function">DEFCONSTANT</code></a></span></dt><dt><span class="section"><a href="flow-dict.html#fcase">5.1.2. Macro <code class="function">EXT:FCASE</code></a></span></dt><dt><span class="section"><a href="flow-dict.html#xor">5.1.3. Function <code class="function">EXT:XOR</code></a></span></dt><dt><span class="section"><a href="flow-dict.html#eq">5.1.4. Function <code class="function">EQ</code></a></span></dt><dt><span class="section"><a href="flow-dict.html#sym-fun">5.1.5. Function <code class="function">SYMBOL-FUNCTION</code></a></span></dt><dt><span class="section"><a href="flow-dict.html#setf">5.1.6. Macro <code class="function">SETF</code></a></span></dt><dt><span class="section"><a href="flow-dict.html#func">5.1.7. Special Operator <code class="function">FUNCTION</code></a></span></dt><dt><span class="section"><a href="flow-dict.html#def-sym-mac">5.1.8. Macro <code class="function">DEFINE-SYMBOL-MACRO</code></a></span></dt><dt><span class="section"><a href="flow-dict.html#lambda">5.1.9. Macro <code class="function">LAMBDA</code></a></span></dt><dt><span class="section"><a href="flow-dict.html#defun">5.1.10. Macros <code class="function">DEFUN</code> &amp; <code class="function">DEFMACRO</code></a></span></dt></dl></div><p><a id="fle"></a><b>Function <a href="http://www.lisp.org/HyperSpec/Body/fun_function-_a-expression.html" target="_top"><code class="function">FUNCTION-LAMBDA-EXPRESSION</code></a></b>The <em class="replaceable"><code>name</code></em> of a <a href="dffi.html" title="31.3. The Foreign Function Call Facility"><code class="classname">FFI:FOREIGN-FUNCTION</code></a> is a <span class="emphasis"><em>string</em></span>
(the name of the underlying <a href="http://www.eskimo.com/~scs/C-faq/top.html" target="_top"><span><strong class="command">C</strong></span></a> function), not a lisp <a href="http://www.lisp.org/HyperSpec/Body/glo_f.html#function_name" target="_top">function name</a>.
</p><p><a id="des-bind"></a><b>Macro <a href="http://www.lisp.org/HyperSpec/Body/mac_destructuring-bind.html" target="_top"><code class="function">DESTRUCTURING-BIND</code></a></b>This macro does not perform full error checking.</p><p><a id="macro-special"></a><b>Macros <a href="http://www.lisp.org/HyperSpec/Body/mac_prog1cm_prog2.html" target="_top"><code class="function">PROG1</code></a>, <a href="http://www.lisp.org/HyperSpec/Body/mac_prog1cm_prog2.html" target="_top"><code class="function">PROG2</code></a>, <a href="http://www.lisp.org/HyperSpec/Body/mac_and.html" target="_top"><code class="function">AND</code></a>,
<a href="http://www.lisp.org/HyperSpec/Body/mac_or.html" target="_top"><code class="function">OR</code></a>, <a href="http://www.lisp.org/HyperSpec/Body/mac_psetq.html" target="_top"><code class="function">PSETQ</code></a>, <a href="http://www.lisp.org/HyperSpec/Body/mac_whencm_unless.html" target="_top"><code class="function">WHEN</code></a>, <a href="http://www.lisp.org/HyperSpec/Body/mac_whencm_unless.html" target="_top"><code class="function">UNLESS</code></a>, <a href="http://www.lisp.org/HyperSpec/Body/mac_cond.html" target="_top"><code class="function">COND</code></a>, <a href="http://www.lisp.org/HyperSpec/Body/mac_casecm_ccasecm_ecase.html" target="_top"><code class="function">CASE</code></a>, <a href="http://www.lisp.org/HyperSpec/Body/mac_multiple-value-list.html" target="_top"><code class="function">MULTIPLE-VALUE-LIST</code></a>,
<a href="http://www.lisp.org/HyperSpec/Body/mac_multiple-value-bind.html" target="_top"><code class="function">MULTIPLE-VALUE-BIND</code></a>, <a href="http://www.lisp.org/HyperSpec/Body/mac_multiple-value-setq.html" target="_top"><code class="function">MULTIPLE-VALUE-SETQ</code></a></b>These macros are implemented as special operators (as permitted by
<a href="http://www.lisp.org/HyperSpec/Body/sec_3-1-2-1-2-2.html" target="_top">Section 3.1.2.1.2.2</a>)
and, as such, are rather efficient.</p><div class="section" lang="en" xml:lang="en"><div class="titlepage"><div><div><h3 class="title"><a id="defconstant"></a>5.1.1. Macro <a href="http://www.lisp.org/HyperSpec/Body/mac_defconstant.html" target="_top"><code class="function">DEFCONSTANT</code></a></h3></div></div></div><p>The initial value is <span class="strong"><strong>not</strong></span> evaluated at compile time,
just like with <a href="http://www.lisp.org/HyperSpec/Body/mac_defparametercm_defvar.html" target="_top"><code class="function">DEFVAR</code></a> and <a href="http://www.lisp.org/HyperSpec/Body/mac_defparametercm_defvar.html" target="_top"><code class="function">DEFPARAMETER</code></a>.
Use <a href="http://www.lisp.org/HyperSpec/Body/speope_eval-when.html" target="_top"><code class="function">EVAL-WHEN</code></a> if you need the value at compile time.</p><p>It is an error if a <a href="http://www.lisp.org/HyperSpec/Body/mac_defconstant.html" target="_top"><code class="function">DEFCONSTANT</code></a> variable is bound at the moment
the <a href="http://www.lisp.org/HyperSpec/Body/mac_defconstant.html" target="_top"><code class="function">DEFCONSTANT</code></a> is executed, but <a href="http://www.lisp.org/HyperSpec/Body/mac_defconstant.html" target="_top"><code class="function">DEFCONSTANT</code></a> does not check
this.</p><p><a href="http://www.lisp.org/HyperSpec/Body/sec_3-1-2-1-1-3.html" target="_top">constant variable</a>s may not be bound dynamically or lexically.</p></div><div class="section" lang="en" xml:lang="en"><div class="titlepage"><div><div><h3 class="title"><a id="fcase"></a>5.1.2. Macro <code class="function">EXT:FCASE</code></h3></div></div></div><p>This macro allows specifying the test for <a href="http://www.lisp.org/HyperSpec/Body/mac_casecm_ccasecm_ecase.html" target="_top"><code class="function">CASE</code></a>, e.g.,
</p><pre class="programlisting">
(fcase string= (subseq foo 0 (position #\Space foo))
("first" 1)
(("second" "two") 2)
(("true" "yes") t)
(otherwise nil))
</pre><p>
is the same as
</p><pre class="programlisting">
(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)))
</pre><p>
If you use a built-in <a href="http://www.lisp.org/HyperSpec/Body/syscla_hash-table.html" target="_top"><code class="classname">HASH-TABLE</code></a> test (see <a href="hash-dict.html#ht-test" title="18.1.3. Function HASH-TABLE-TEST">Section 18.1.3, “Function <code class="function">HASH-TABLE-TEST</code></a>)
as the test (e.g., <a href="http://www.lisp.org/HyperSpec/Body/fun_equal.html" target="_top"><code class="function">EQUAL</code></a> instead of <a href="http://www.lisp.org/HyperSpec/Body/fun_stringeqc_ng-not-lessp.html" target="_top"><code class="function">STRING=</code></a> above, but not a test
defined using <a href="hash-dict.html#defhash" title="18.1.2. Macro EXT:DEFINE-HASH-TABLE-TEST"><code class="function">EXT:DEFINE-HASH-TABLE-TEST</code></a>), the compiler will be able to optimize
the <code class="function">EXT:FCASE</code> form better than the corresponding
<a href="http://www.lisp.org/HyperSpec/Body/mac_cond.html" target="_top"><code class="function">COND</code></a> form.</p></div><div class="section" lang="en" xml:lang="en"><div class="titlepage"><div><div><h3 class="title"><a id="xor"></a>5.1.3. Function <code class="function">EXT:XOR</code></h3></div></div></div><p>This function checks that exactly one of its arguments is non-<a href="http://www.lisp.org/HyperSpec/Body/convar_nil.html" target="_top"><code class="constant">NIL</code></a>
and, if this is the case, returns its value and index in the argument
list as <a href="http://www.lisp.org/HyperSpec/Body/glo_m.html#multiple_values" target="_top">multiple values</a>, otherwise returns <a href="http://www.lisp.org/HyperSpec/Body/convar_nil.html" target="_top"><code class="constant">NIL</code></a>.</p></div><div class="section" lang="en" xml:lang="en"><div class="titlepage"><div><div><h3 class="title"><a id="eq"></a>5.1.4. Function <a href="http://www.lisp.org/HyperSpec/Body/fun_eq.html" target="_top"><code class="function">EQ</code></a></h3></div></div></div><p><a href="http://www.lisp.org/HyperSpec/Body/fun_eq.html" target="_top"><code class="function">EQ</code></a> compares <a href="http://www.lisp.org/HyperSpec/Body/syscla_character.html" target="_top"><code class="classname">CHARACTER</code></a>s and <a href="http://www.lisp.org/HyperSpec/Body/typ_fixnum.html" target="_top"><code class="classname">FIXNUM</code></a>s as <a href="http://www.lisp.org/HyperSpec/Body/fun_eql.html" target="_top"><code class="function">EQL</code></a> does.
No unnecessary copies are made of <a href="http://www.lisp.org/HyperSpec/Body/syscla_character.html" target="_top"><code class="classname">CHARACTER</code></a>s and <a href="http://www.lisp.org/HyperSpec/Body/syscla_number.html" target="_top"><code class="classname">NUMBER</code></a>s.
Nevertheless, one should use <a href="http://www.lisp.org/HyperSpec/Body/fun_eql.html" target="_top"><code class="function">EQL</code></a> as it is more portable across <a href="http://www.lisp.org" target="_top"><span><strong class="command">Common Lisp</strong></span></a>
implementations.</p><p><code class="code">(<a href="http://www.lisp.org/HyperSpec/Body/speope_letcm_letst.html" target="_top"><code class="function">LET</code></a> ((x y)) (<a href="http://www.lisp.org/HyperSpec/Body/fun_eq.html" target="_top"><code class="function">EQ</code></a> x x))</code> always
returns <a href="http://www.lisp.org/HyperSpec/Body/convar_t.html" target="_top"><code class="constant">T</code></a>, regardless of <em class="replaceable"><code>y</code></em>.</p><div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Warning</h3><p><code class="code">(<a href="http://www.lisp.org/HyperSpec/Body/fun_eq.html" target="_top"><code class="function">EQ</code></a> x x)</code> might not be
<a href="http://www.lisp.org/HyperSpec/Body/convar_t.html" target="_top"><code class="constant">T</code></a> for a <a href="dffi.html#dffi-variables" title="31.3.5. Foreign variables"><code class="classname">FFI:FOREIGN-VARIABLE</code></a> <em class="replaceable"><code>x</code></em>.</p></div></div><div class="section" lang="en" xml:lang="en"><div class="titlepage"><div><div><h3 class="title"><a id="sym-fun"></a>5.1.5. Function <a href="http://www.lisp.org/HyperSpec/Body/acc_symbol-function.html" target="_top"><code class="function">SYMBOL-FUNCTION</code></a></h3></div></div></div><p><code class="code">(<a href="http://www.lisp.org/HyperSpec/Body/mac_setfcm_psetf.html" target="_top"><code class="function">SETF</code></a> (<a href="http://www.lisp.org/HyperSpec/Body/acc_symbol-function.html" target="_top"><code class="function">SYMBOL-FUNCTION</code></a> <em class="replaceable"><code>symbol</code></em>) <em class="replaceable"><code>object</code></em>)</code>
requires <em class="replaceable"><code>object</code></em> to be either a function, a <a href="http://www.lisp.org/HyperSpec/Body/acc_symbol-function.html" target="_top"><code class="function">SYMBOL-FUNCTION</code></a> return
value, or a <a href="http://www.lisp.org/HyperSpec/Body/sec_3-1-3.html" target="_top">lambda expression</a>. The <a href="http://www.lisp.org/HyperSpec/Body/sec_3-1-3.html" target="_top">lambda expression</a> is thereby immediately
converted to a <a href="http://www.lisp.org/HyperSpec/Body/syscla_function.html" target="_top"><code class="classname">FUNCTION</code></a>.</p></div><div class="section" lang="en" xml:lang="en"><div class="titlepage"><div><div><h3 class="title"><a id="setf"></a>5.1.6. Macro <a href="http://www.lisp.org/HyperSpec/Body/mac_setfcm_psetf.html" target="_top"><code class="function">SETF</code></a></h3></div></div></div><p>Additional <a href="http://www.lisp.org/HyperSpec/Body/glo_p.html#place" target="_top">place</a>s:
</p><div class="variablelist"><dl><dt><span class="term"><a href="http://www.lisp.org/HyperSpec/Body/fun_funcall.html" target="_top"><code class="function">FUNCALL</code></a></span></dt><dd><code class="code">(<a href="http://www.lisp.org/HyperSpec/Body/mac_setfcm_psetf.html" target="_top"><code class="function">SETF</code></a> (<a href="http://www.lisp.org/HyperSpec/Body/fun_funcall.html" target="_top"><code class="function">FUNCALL</code></a> #'<em class="replaceable"><code>symbol</code></em> ...)
<em class="replaceable"><code>object</code></em>)</code> and
<code class="code">(<a href="http://www.lisp.org/HyperSpec/Body/mac_setfcm_psetf.html" target="_top"><code class="function">SETF</code></a> (<a href="http://www.lisp.org/HyperSpec/Body/fun_funcall.html" target="_top"><code class="function">FUNCALL</code></a> '<em class="replaceable"><code>symbol</code></em> ...) <em class="replaceable"><code>object</code></em>)</code>
are equivalent to <code class="code">(<a href="http://www.lisp.org/HyperSpec/Body/mac_setfcm_psetf.html" target="_top"><code class="function">SETF</code></a> (<em class="replaceable"><code>symbol</code></em> ...) <em class="replaceable"><code>object</code></em>)</code>.
</dd><dt><span class="term"><a href="http://www.lisp.org/HyperSpec/Body/speope_progn.html" target="_top"><code class="function">PROGN</code></a></span></dt><dd><code class="code">(<a href="http://www.lisp.org/HyperSpec/Body/mac_setfcm_psetf.html" target="_top"><code class="function">SETF</code></a> (<a href="http://www.lisp.org/HyperSpec/Body/speope_progn.html" target="_top"><code class="function">PROGN</code></a> <em class="replaceable"><code>form</code></em> ... <em class="replaceable"><code>place</code></em>)
<em class="replaceable"><code>object</code></em>)</code></dd><dt><span class="term"><a href="http://www.lisp.org/HyperSpec/Body/speope_locally.html" target="_top"><code class="function">LOCALLY</code></a></span></dt><dd><code class="code">(<a href="http://www.lisp.org/HyperSpec/Body/mac_setfcm_psetf.html" target="_top"><code class="function">SETF</code></a> (<a href="http://www.lisp.org/HyperSpec/Body/speope_locally.html" target="_top"><code class="function">LOCALLY</code></a> <em class="replaceable"><code>declaration</code></em> ...
<em class="replaceable"><code>form</code></em> ... <em class="replaceable"><code>place</code></em>) <em class="replaceable"><code>object</code></em>)</code>
</dd><dt><span class="term"><a href="http://www.lisp.org/HyperSpec/Body/speope_if.html" target="_top"><code class="function">IF</code></a></span></dt><dd><code class="code">(<a href="http://www.lisp.org/HyperSpec/Body/mac_setfcm_psetf.html" target="_top"><code class="function">SETF</code></a> (<a href="http://www.lisp.org/HyperSpec/Body/speope_if.html" target="_top"><code class="function">IF</code></a> <em class="replaceable"><code>condition</code></em>
<em class="replaceable"><code>place<sub>1</sub></code></em>
<em class="replaceable"><code>place<sub>2</sub></code></em>)
<em class="replaceable"><code>object</code></em>)</code></dd><dt><span class="term"><a href="http://www.lisp.org/HyperSpec/Body/fun_set-dispa_ro-character.html" target="_top"><code class="function">GET-DISPATCH-MACRO-CHARACTER</code></a></span></dt><dd><code class="code">(<a href="http://www.lisp.org/HyperSpec/Body/mac_setfcm_psetf.html" target="_top"><code class="function">SETF</code></a> (<a href="http://www.lisp.org/HyperSpec/Body/fun_set-dispa_ro-character.html" target="_top"><code class="function">GET-DISPATCH-MACRO-CHARACTER</code></a> ...)
...)</code> calls <a href="http://www.lisp.org/HyperSpec/Body/fun_set-dispa_ro-character.html" target="_top"><code class="function">SET-DISPATCH-MACRO-CHARACTER</code></a>.
</dd><dt><span class="term"><a href="num-concepts.html#lfd"><code class="function">EXT:LONG-FLOAT-DIGITS</code></a>:</span></dt><dd><code class="code">(<a href="http://www.lisp.org/HyperSpec/Body/mac_setfcm_psetf.html" target="_top"><code class="function">SETF</code></a> (<a href="num-concepts.html#lfd"><code class="function">EXT:LONG-FLOAT-DIGITS</code></a>) <em class="replaceable"><code>digits</code></em>)</code> sets the
default mantissa length of <a href="http://www.lisp.org/HyperSpec/Body/typ_short-flo_m_long-float.html" target="_top"><code class="classname">LONG-FLOAT</code></a>s to <em class="replaceable"><code>digits</code></em> bits.
</dd><dt><span class="term"><a href="http://www.lisp.org/HyperSpec/Body/fun_values-list.html" target="_top"><code class="function">VALUES-LIST</code></a></span></dt><dd><p><code class="code">(<a href="http://www.lisp.org/HyperSpec/Body/mac_setfcm_psetf.html" target="_top"><code class="function">SETF</code></a> (<a href="http://www.lisp.org/HyperSpec/Body/fun_values-list.html" target="_top"><code class="function">VALUES-LIST</code></a> <em class="replaceable"><code>list</code></em>) <em class="replaceable"><code>form</code></em>)</code>
is equivalent to <code class="code">(<a href="http://www.lisp.org/HyperSpec/Body/fun_values-list.html" target="_top"><code class="function">VALUES-LIST</code></a> (<a href="http://www.lisp.org/HyperSpec/Body/mac_setfcm_psetf.html" target="_top"><code class="function">SETF</code></a> <em class="replaceable"><code>list</code></em>
(<a href="http://www.lisp.org/HyperSpec/Body/mac_multiple-value-list.html" target="_top"><code class="function">MULTIPLE-VALUE-LIST</code></a> <em class="replaceable"><code>form</code></em>)))</code>.</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>Note that this <a href="http://www.lisp.org/HyperSpec/Body/glo_p.html#place" target="_top">place</a> is restricted: it can only be
used in <a href="http://www.lisp.org/HyperSpec/Body/mac_setfcm_psetf.html" target="_top"><code class="function">SETF</code></a>, <a href="macros3.html#letf" title="30.11.2. Macros EXT:LETF &amp; EXT:LETF*"><code class="function">EXT:LETF</code></a>, <a href="macros3.html#letf" title="30.11.2. Macros EXT:LETF &amp; EXT:LETF*"><code class="function">EXT:LETF*</code></a>, not in other positions.
</p></div></dd></dl></div><p><a href="http://www.lisp.org/HyperSpec/Body/sec_3-4-1.html" target="_top"><code class="literal">&amp;KEY</code></a> markers in <a href="http://www.lisp.org/HyperSpec/Body/mac_defsetf.html" target="_top"><code class="function">DEFSETF</code></a> <a href="lalist.html" title="3.4. Lambda Lists&#10; [CLHS-3.4]">lambda list</a>s are supported, but the
corresponding keywords must appear literally in the program text.</p><p><code class="code">(<a href="http://www.lisp.org/HyperSpec/Body/fun_get-setf-expansion.html" target="_top"><code class="function">GET-SETF-EXPANSION</code></a> <em class="replaceable"><code>form</code></em> <a href="http://www.lisp.org/HyperSpec/Body/sec_3-4-1.html" target="_top"><code class="literal">&amp;OPTIONAL</code></a> <em class="replaceable"><code><a href="http://www.lisp.org/HyperSpec/sec_3-1-1-4.html" target="_top">environment</a></code></em>)</code>,
<code class="code">(EXT:GET-SETF-METHOD <em class="replaceable"><code>form</code></em> <a href="http://www.lisp.org/HyperSpec/Body/sec_3-4-1.html" target="_top"><code class="literal">&amp;OPTIONAL</code></a> <em class="replaceable"><code><a href="http://www.lisp.org/HyperSpec/sec_3-1-1-4.html" target="_top">environment</a></code></em>)</code>, and
<code class="code">(EXT:GET-SETF-METHOD-MULTIPLE-VALUE <em class="replaceable"><code>form</code></em> <a href="http://www.lisp.org/HyperSpec/Body/sec_3-4-1.html" target="_top"><code class="literal">&amp;OPTIONAL</code></a>
<em class="replaceable"><code><a href="http://www.lisp.org/HyperSpec/sec_3-1-1-4.html" target="_top">environment</a></code></em>)</code> receive as optional argument <em class="replaceable"><code><a href="http://www.lisp.org/HyperSpec/sec_3-1-1-4.html" target="_top">environment</a></code></em> the environment
necessary for macro expansions. In <a href="http://www.lisp.org/HyperSpec/Body/mac_define-setf-expander.html" target="_top"><code class="function">DEFINE-SETF-EXPANDER</code></a>
and <code class="function">EXT:DEFINE-SETF-METHOD</code> <a href="lalist.html" title="3.4. Lambda Lists&#10; [CLHS-3.4]">lambda list</a>s, one can
specify <a href="http://www.lisp.org/HyperSpec/Body/sec_3-4-4.html" target="_top"><code class="literal">&amp;ENVIRONMENT</code></a> and a variable, which will be bound to the
environment. This environment should be passed to all calls of
<a href="http://www.lisp.org/HyperSpec/Body/fun_get-setf-expansion.html" target="_top"><code class="function">GET-SETF-EXPANSION</code></a>, <code class="function">EXT:GET-SETF-METHOD</code> and
<code class="function">EXT:GET-SETF-METHOD-MULTIPLE-VALUE</code>. If this is
done, even local macros will be interpreted as places correctly.</p><p>Attempts to modify read-only data will <a href="http://www.lisp.org/HyperSpec/Body/fun_signal.html" target="_top"><code class="function">SIGNAL</code></a> an <a href="http://www.lisp.org/HyperSpec/Body/contyp_error.html" target="_top"><code class="classname">ERROR</code></a>.
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.</p><p>See also <a href="macros3.html#letf" title="30.11.2. Macros EXT:LETF &amp; EXT:LETF*">Section 30.11.2, “Macros <code class="function">EXT:LETF</code> &amp; <code class="function">EXT:LETF*</code></a>.</p></div><div class="section" lang="en" xml:lang="en"><div class="titlepage"><div><div><h3 class="title"><a id="func"></a>5.1.7. Special Operator <a href="http://www.lisp.org/HyperSpec/Body/speope_function.html" target="_top"><code class="function">FUNCTION</code></a></h3></div></div></div><p><code class="code">(<a href="http://www.lisp.org/HyperSpec/Body/speope_function.html" target="_top"><code class="function">FUNCTION</code></a> <em class="replaceable"><code>symbol</code></em>)</code> returns the local function
definition established by <a href="http://www.lisp.org/HyperSpec/Body/speope_fletcm_scm_macrolet.html" target="_top"><code class="function">FLET</code></a> or <a href="http://www.lisp.org/HyperSpec/Body/speope_fletcm_scm_macrolet.html" target="_top"><code class="function">LABELS</code></a>, if it exists, otherwise
the global function definition.</p><p><code class="code">(<a href="http://www.lisp.org/HyperSpec/Body/fun_special-operator-p.html" target="_top"><code class="function">SPECIAL-OPERATOR-P</code></a> <em class="replaceable"><code>symbol</code></em>)</code> returns <a href="http://www.lisp.org/HyperSpec/Body/convar_nil.html" target="_top"><code class="constant">NIL</code></a> or
<a href="http://www.lisp.org/HyperSpec/Body/convar_t.html" target="_top"><code class="constant">T</code></a>. If it returns <a href="http://www.lisp.org/HyperSpec/Body/convar_t.html" target="_top"><code class="constant">T</code></a>, then <code class="code">(<a href="http://www.lisp.org/HyperSpec/Body/acc_symbol-function.html" target="_top"><code class="function">SYMBOL-FUNCTION</code></a>
<em class="replaceable"><code>symbol</code></em>)</code> returns the (useless) special operator handler.</p></div><div class="section" lang="en" xml:lang="en"><div class="titlepage"><div><div><h3 class="title"><a id="def-sym-mac"></a>5.1.8. Macro <a href="http://www.lisp.org/HyperSpec/Body/mac_define-symbol-macro.html" target="_top"><code class="function">DEFINE-SYMBOL-MACRO</code></a></h3></div></div></div><p>The macro <a href="http://www.lisp.org/HyperSpec/Body/mac_define-symbol-macro.html" target="_top"><code class="function">DEFINE-SYMBOL-MACRO</code></a> establishes <a href="http://www.lisp.org/HyperSpec/Body/mac_define-symbol-macro.html" target="_top"><code class="classname">SYMBOL-MACRO</code></a>s with
global scope (as opposed to <a href="http://www.lisp.org/HyperSpec/Body/mac_define-symbol-macro.html" target="_top"><code class="classname">SYMBOL-MACRO</code></a>s defined with
<a href="http://www.lisp.org/HyperSpec/Body/speope_symbol-macrolet.html" target="_top"><code class="function">SYMBOL-MACROLET</code></a>, which have local scope):
<code class="code">(<a href="http://www.lisp.org/HyperSpec/Body/mac_define-symbol-macro.html" target="_top"><code class="function">DEFINE-SYMBOL-MACRO</code></a> <em class="replaceable"><code>symbol</code></em>
<em class="replaceable"><code>expansion</code></em>)</code>.</p><p>The function
<strong class="first"><em class="firstterm"><a href="flow-dict.html#symbol-mex"><code class="function">EXT:SYMBOL-MACRO-EXPAND</code></a><a id="symbol-mex" class="indexterm"></a></em></strong>
tests for a <a href="http://www.lisp.org/HyperSpec/Body/mac_define-symbol-macro.html" target="_top"><code class="classname">SYMBOL-MACRO</code></a>: If <em class="replaceable"><code>symbol</code></em> is defined as a <a href="http://www.lisp.org/HyperSpec/Body/mac_define-symbol-macro.html" target="_top"><code class="classname">SYMBOL-MACRO</code></a>
in the <a href="http://www.lisp.org/HyperSpec/Body/sec_3-1-1-1.html" target="_top">global environment</a>, <code class="code">(<a href="flow-dict.html#symbol-mex"><code class="function">EXT:SYMBOL-MACRO-EXPAND</code></a> <em class="replaceable"><code>symbol</code></em>)</code> returns two
values, <a href="http://www.lisp.org/HyperSpec/Body/convar_t.html" target="_top"><code class="constant">T</code></a> and the expansion; otherwise it returns <a href="http://www.lisp.org/HyperSpec/Body/convar_nil.html" target="_top"><code class="constant">NIL</code></a>.</p><p><a href="flow-dict.html#symbol-mex"><code class="function">EXT:SYMBOL-MACRO-EXPAND</code></a> is a special case of <a href="http://www.lisp.org/HyperSpec/Body/fun_macroexpa_acroexpand-1.html" target="_top"><code class="function">MACROEXPAND-1</code></a>. <a href="http://www.lisp.org/HyperSpec/Body/fun_macroexpa_acroexpand-1.html" target="_top"><code class="function">MACROEXPAND-1</code></a>
can also test whether a symbol is defined as a <a href="http://www.lisp.org/HyperSpec/Body/mac_define-symbol-macro.html" target="_top"><code class="classname">SYMBOL-MACRO</code></a> in <a href="http://www.lisp.org/HyperSpec/Body/sec_3-1-1-3.html" target="_top">lexical environment</a>s
other than the <a href="http://www.lisp.org/HyperSpec/Body/sec_3-1-1-1.html" target="_top">global environment</a>.</p><p>Calling <a href="http://www.lisp.org/HyperSpec/Body/fun_boundp.html" target="_top"><code class="function">BOUNDP</code></a> on a symbol defined as a <a href="http://www.lisp.org/HyperSpec/Body/mac_define-symbol-macro.html" target="_top"><code class="classname">SYMBOL-MACRO</code></a> returns
<a href="http://www.lisp.org/HyperSpec/Body/convar_t.html" target="_top"><code class="constant">T</code></a>.</p><p>Calling <a href="http://www.lisp.org/HyperSpec/Body/acc_symbol-value.html" target="_top"><code class="function">SYMBOL-VALUE</code></a> on a symbol defined as a <a href="http://www.lisp.org/HyperSpec/Body/mac_define-symbol-macro.html" target="_top"><code class="classname">SYMBOL-MACRO</code></a>
returns the value of the expansion. Calling <a href="http://www.lisp.org/HyperSpec/Body/fun_set.html" target="_top"><code class="function">SET</code></a> on a symbol defined
as a <a href="http://www.lisp.org/HyperSpec/Body/mac_define-symbol-macro.html" target="_top"><code class="classname">SYMBOL-MACRO</code></a> calls <a href="http://www.lisp.org/HyperSpec/Body/mac_setfcm_psetf.html" target="_top"><code class="function">SETF</code></a> on the expansion.</p><p>Calling <a href="http://www.lisp.org/HyperSpec/Body/fun_makunbound.html" target="_top"><code class="function">MAKUNBOUND</code></a> on a symbol defined as a <a href="http://www.lisp.org/HyperSpec/Body/mac_define-symbol-macro.html" target="_top"><code class="classname">SYMBOL-MACRO</code></a>
removes the <a href="http://www.lisp.org/HyperSpec/Body/mac_define-symbol-macro.html" target="_top"><code class="classname">SYMBOL-MACRO</code></a> definition.</p></div><div class="section" lang="en" xml:lang="en"><div class="titlepage"><div><div><h3 class="title"><a id="lambda"></a>5.1.9. Macro <a href="http://www.lisp.org/HyperSpec/Body/mac_lambda.html" target="_top"><code class="function">LAMBDA</code></a></h3></div></div></div><p><b>Constant <a href="http://www.lisp.org/HyperSpec/Body/convar_lambda_ist-keywords.html" target="_top"><code class="constant">LAMBDA-LIST-KEYWORDS</code></a></b><code class="code">(<a href="http://www.lisp.org/HyperSpec/Body/sec_3-4-1.html" target="_top"><code class="literal">&amp;OPTIONAL</code></a> <a href="http://www.lisp.org/HyperSpec/Body/sec_3-4-1.html" target="_top"><code class="literal">&amp;REST</code></a> <a href="http://www.lisp.org/HyperSpec/Body/sec_3-4-1.html" target="_top"><code class="literal">&amp;KEY</code></a> <a href="http://www.lisp.org/HyperSpec/Body/sec_3-4-1.html" target="_top"><code class="literal">&amp;ALLOW-OTHER-KEYS</code></a>
<a href="http://www.lisp.org/HyperSpec/Body/sec_3-4-1.html" target="_top"><code class="literal">&amp;AUX</code></a> <a href="http://www.lisp.org/HyperSpec/Body/sec_3-4-4.html" target="_top"><code class="literal">&amp;BODY</code></a> <a href="http://www.lisp.org/HyperSpec/Body/sec_3-4-4.html" target="_top"><code class="literal">&amp;WHOLE</code></a> <a href="http://www.lisp.org/HyperSpec/Body/sec_3-4-4.html" target="_top"><code class="literal">&amp;ENVIRONMENT</code></a>)</code></p><div class="table"><a id="values-limits-table"></a><p class="title"><b>Table 5.1. Function call limits</b></p><table summary="Function call limits" border="1"><colgroup><col /><col /></colgroup><tbody><tr><td align="center"><a href="http://www.lisp.org/HyperSpec/Body/convar_call-a_uments-limit.html" target="_top"><code class="constant">CALL-ARGUMENTS-LIMIT</code></a></td><td align="center">2<sup>12</sup>=4096</td></tr><tr><td align="center"><a href="http://www.lisp.org/HyperSpec/Body/convar_multip_values-limit.html" target="_top"><code class="constant">MULTIPLE-VALUES-LIMIT</code></a></td><td align="center">2<sup>7</sup>=128</td></tr><tr><td align="center"><a href="http://www.lisp.org/HyperSpec/Body/convar_lambda_meters-limit.html" target="_top"><code class="constant">LAMBDA-PARAMETERS-LIMIT</code></a></td><td align="center">2<sup>12</sup>=4096</td></tr></tbody></table></div></div><div class="section" lang="en" xml:lang="en"><div class="titlepage"><div><div><h3 class="title"><a id="defun"></a>5.1.10. Macros <a href="http://www.lisp.org/HyperSpec/Body/mac_defun.html" target="_top"><code class="function">DEFUN</code></a> &amp; <a href="http://www.lisp.org/HyperSpec/Body/mac_defmacro.html" target="_top"><code class="function">DEFMACRO</code></a></h3></div></div></div><p><a href="http://www.lisp.org/HyperSpec/Body/mac_defun.html" target="_top"><code class="function">DEFUN</code></a> and <a href="http://www.lisp.org/HyperSpec/Body/mac_defmacro.html" target="_top"><code class="function">DEFMACRO</code></a> are allowed in non-toplevel positions. As
an example, consider the old ([<a href="references.html#CLtL1" title="[CLtL1]"><abbr class="abbrev">CLtL1</abbr></a>]) definition of <a href="http://www.lisp.org/HyperSpec/Body/fun_gensym.html" target="_top"><code class="function">GENSYM</code></a>:</p><pre class="programlisting">
(let ((gensym-prefix "G")
(gensym-count 1))
(defun gensym (&amp;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))))
</pre><p><a id="suppress-check-redef"></a><b>Variable <a href="flow-dict.html#suppress-check-redef"><code class="varname">CUSTOM:*SUPPRESS-CHECK-REDEFINITION*</code></a></b>When <strong class="first"><em class="firstterm"><a href="flow-dict.html#suppress-check-redef"><code class="varname">CUSTOM:*SUPPRESS-CHECK-REDEFINITION*</code></a></em></strong> is <a href="http://www.lisp.org/HyperSpec/Body/convar_nil.html" target="_top"><code class="constant">NIL</code></a>,
<a href="http://clisp.cons.org" target="_top"><span><strong class="command">CLISP</strong></span></a> issues a <a href="http://www.lisp.org/HyperSpec/Body/contyp_warning.html" target="_top"><code class="classname">WARNING</code></a> when a function (macro, variable, class,
etc) is redefined in a different file than its original definition.
It is <span class="strong"><strong>not</strong></span> a good idea to set this variable to <a href="http://www.lisp.org/HyperSpec/Body/convar_t.html" target="_top"><code class="constant">T</code></a>.
</p><p><a id="defun-accept-spelalist"></a><b>Variable <a href="flow-dict.html#defun-accept-spelalist"><code class="varname">CUSTOM:*DEFUN-ACCEPT-SPECIALIZED-LAMBDA-LIST*</code></a></b>When <strong class="first"><em class="firstterm"><a href="flow-dict.html#defun-accept-spelalist"><code class="varname">CUSTOM:*DEFUN-ACCEPT-SPECIALIZED-LAMBDA-LIST*</code></a></em></strong> is
non-<a href="http://www.lisp.org/HyperSpec/Body/convar_nil.html" target="_top"><code class="constant">NIL</code></a>, <a href="http://www.lisp.org/HyperSpec/Body/mac_defun.html" target="_top"><code class="function">DEFUN</code></a> accepts <a href="http://www.lisp.org/HyperSpec/Body/sec_3-4-3.html" target="_top">specialized lambda list</a>s, converting type-parameter
associations to type declarations:
</p><pre class="programlisting">(defun f ((x list) (y integer)) ...)</pre><p>
is equivalent to
</p><pre class="programlisting">(defun f (x y) (declare (type list x) (type integer y)) ...)</pre><p>
This extension is disabled by <a href="clisp.html#opt-ansi" class="olink"><code class="option">-ansi</code></a> and by setting <a href="ansi.html" class="olink"><code class="varname">CUSTOM:*ANSI*</code></a> to <a href="http://www.lisp.org/HyperSpec/Body/convar_t.html" target="_top"><code class="constant">T</code></a>,
but can be re-enabled by setting <a href="flow-dict.html#defun-accept-spelalist"><code class="varname">CUSTOM:*DEFUN-ACCEPT-SPECIALIZED-LAMBDA-LIST*</code></a> explicitly.
</p></div></div><div class="bookinfo"><hr width="100%" /><table width="100%" summary="impnotes meta info"><th><td align="left">These notes document <a href="http://clisp.cons.org" target="_top"><span><strong class="command">CLISP</strong></span></a> version 2.36</td><td align="right">Last modified: 2005-12-04</td></th></table></div><div class="custom-footer"><hr width="100%" /><table width="100%"><tr><td align="left"><a href="http://clisp.cons.org"><img src="clisp.png" width="48" height="48" alt="[CLISP home]" /></a></td><td align="center"><a href="http://sourceforge.net/donate/index.php?group_id=1355"><img src="http://images.sourceforge.net/images/project-support.jpg" width="88" height="32" border="0" alt="[Support This Project]" /></a></td><td align="right"><a href="http://sourceforge.net"><img width="125" height="37" alt="[SourceForge]" src="http://sflogo.sourceforge.net/sflogo.php?group_id=1355&amp;type=2&amp;page=flow-dict" /></a></td></tr></table></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="data.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="data.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="iteration.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Chapter 5. Data and Control Flow
[CLHS-5] </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> Chapter 6. Iteration
[CLHS-6]</td></tr></table></div></body></html>