<htmlxmlns="http://www.w3.org/1999/xhtml"xmlns:cf="http://docbook.sourceforge.net/xmlns/chunkfast/1.0"><head><metahttp-equiv="Content-Type"content="text/html; charset=UTF-8"/><title>5.1. The Data and Control Flow Dictionary

[CLHS-5.3]</th></tr><tr><tdwidth="20%"align="left"><aaccesskey="p"href="data.html">Prev</a></td><thwidth="60%"align="center">Chapter 5. Data and Control Flow

[CLHS-5]</th><tdwidth="20%"align="right"><aaccesskey="n"href="iteration.html">Next</a></td></tr></table><hr/></div><divclass="section"lang="en"xml:lang="en"><divclass="titlepage"><div><div><h2class="title"style="clear: both"><aid="flow-dict"></a>5.1. The Data and Control Flow Dictionary

(the name of the underlying <ahref="http://www.eskimo.com/~scs/C-faq/top.html"target="_top"><span><strongclass="command">C</strong></span></a> function), not a lisp <ahref="http://www.lisp.org/HyperSpec/Body/glo_f.html#function_name"target="_top">function name</a>.

<ahref="http://www.lisp.org/HyperSpec/Body/mac_multiple-value-bind.html"target="_top"><codeclass="function">MULTIPLE-VALUE-BIND</code></a>, <ahref="http://www.lisp.org/HyperSpec/Body/mac_multiple-value-setq.html"target="_top"><codeclass="function">MULTIPLE-VALUE-SETQ</code></a>. </b>These macros are implemented as special operators (as permitted by

and, as such, are rather efficient.</p><p><b>Macro <ahref="http://www.lisp.org/HyperSpec/Body/mac_defconstant.html"target="_top"><codeclass="function">DEFCONSTANT</code></a>. </b>The initial value is <spanclass="strong"><strong>not</strong></span> evaluated at compile time,

just like with <ahref="http://www.lisp.org/HyperSpec/Body/mac_defparametercm_defvar.html"target="_top"><codeclass="function">DEFVAR</code></a> and <ahref="http://www.lisp.org/HyperSpec/Body/mac_defparametercm_defvar.html"target="_top"><codeclass="function">DEFPARAMETER</code></a>.

Use <ahref="http://www.lisp.org/HyperSpec/Body/speope_eval-when.html"target="_top"><codeclass="function">EVAL-WHEN</code></a> if you need the value at compile time.</p><divclass="section"lang="en"xml:lang="en"><divclass="titlepage"><div><div><h3class="title"><aid="fcase"></a>5.1.1. Macro <codeclass="function">EXT:FCASE</code></h3></div></div></div><p>This macro allows specifying the test for <ahref="http://www.lisp.org/HyperSpec/Body/mac_casecm_ccasecm_ecase.html"target="_top"><codeclass="function">CASE</code></a>, e.g.,

</p><preclass="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><preclass="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>

</p></div><divclass="section"lang="en"xml:lang="en"><divclass="titlepage"><div><div><h3class="title"><aid="xor"></a>5.1.2. Function <codeclass="function">EXT:XOR</code></h3></div></div></div><p>This function checks that exactly one of its arguments is non-<ahref="http://www.lisp.org/HyperSpec/Body/convar_nil.html"target="_top"><codeclass="constant">NIL</code></a>

No unnecessary copies are made of <ahref="http://www.lisp.org/HyperSpec/Body/syscla_character.html"target="_top"><codeclass="classname">CHARACTER</code></a>s and <ahref="http://www.lisp.org/HyperSpec/Body/syscla_number.html"target="_top"><codeclass="classname">NUMBER</code></a>s.

Nevertheless, one should use <ahref="http://www.lisp.org/HyperSpec/Body/fun_eql.html"target="_top"><codeclass="function">EQL</code></a> as it is more portable across <ahref="http://www.lisp.org"target="_top"><span><strongclass="command">Common Lisp</strong></span></a>

requires <emclass="replaceable"><code>object</code></em> to be either a function, a <ahref="http://www.lisp.org/HyperSpec/Body/acc_symbol-function.html"target="_top"><codeclass="function">SYMBOL-FUNCTION</code></a> return

value, or a <ahref="http://www.lisp.org/HyperSpec/Body/sec_3-1-3.html"target="_top">lambda expression</a>. The <ahref="http://www.lisp.org/HyperSpec/Body/sec_3-1-3.html"target="_top">lambda expression</a> is thereby immediately

is equivalent to <codeclass="code">(<ahref="http://www.lisp.org/HyperSpec/Body/fun_values-list.html"target="_top"><codeclass="function">VALUES-LIST</code></a> (<ahref="http://www.lisp.org/HyperSpec/Body/mac_setfcm_psetf.html"target="_top"><codeclass="function">SETF</code></a><emclass="replaceable"><code>list</code></em>

(<ahref="http://www.lisp.org/HyperSpec/Body/mac_multiple-value-list.html"target="_top"><codeclass="function">MULTIPLE-VALUE-LIST</code></a><emclass="replaceable"><code>form</code></em>)))</code>.</p><divclass="note"style="margin-left: 0.5in; margin-right: 0.5in;"><h3class="title">Note</h3><p>Note that this <ahref="http://www.lisp.org/HyperSpec/Body/glo_p.html#place"target="_top">place</a> is restricted: it can only be

used in <ahref="http://www.lisp.org/HyperSpec/Body/mac_setfcm_psetf.html"target="_top"><codeclass="function">SETF</code></a>, <ahref="macros3.html#letf"><codeclass="function">EXT:LETF</code></a>, <ahref="macros3.html#letf"><codeclass="function">EXT:LETF*</code></a>, not in other positions.

</p></div></dd></dl></div><p><ahref="http://www.lisp.org/HyperSpec/Body/sec_3-4-1.html"target="_top"><codeclass="literal">&amp;KEY</code></a> markers in <ahref="http://www.lisp.org/HyperSpec/Body/mac_defsetf.html"target="_top"><codeclass="function">DEFSETF</code></a><ahref="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><codeclass="code">(<ahref="http://www.lisp.org/HyperSpec/Body/fun_get-setf-expansion.html"target="_top"><codeclass="function">GET-SETF-EXPANSION</code></a><emclass="replaceable"><code>form</code></em><ahref="http://www.lisp.org/HyperSpec/Body/sec_3-4-1.html"target="_top"><codeclass="literal">&amp;OPTIONAL</code></a><emclass="replaceable"><code><ahref="http://www.lisp.org/HyperSpec/sec_3-1-1-4.html"target="_top">environment</a></code></em>)</code>,

<codeclass="code">(EXT:GET-SETF-METHOD <emclass="replaceable"><code>form</code></em><ahref="http://www.lisp.org/HyperSpec/Body/sec_3-4-1.html"target="_top"><codeclass="literal">&amp;OPTIONAL</code></a><emclass="replaceable"><code><ahref="http://www.lisp.org/HyperSpec/sec_3-1-1-4.html"target="_top">environment</a></code></em>)</code>, and

necessary for macro expansions. In <ahref="http://www.lisp.org/HyperSpec/Body/mac_define-setf-expander.html"target="_top"><codeclass="function">DEFINE-SETF-EXPANDER</code></a>

and <codeclass="function">EXT:DEFINE-SETF-METHOD</code><ahref="lalist.html"title="3.4. Lambda Lists&#10; [CLHS-3.4]">lambda list</a>s, one can

specify <ahref="http://www.lisp.org/HyperSpec/Body/sec_3-4-4.html"target="_top"><codeclass="literal">&amp;ENVIRONMENT</code></a> and a variable, which will be bound to the

environment. This environment should be passed to all calls of

<ahref="http://www.lisp.org/HyperSpec/Body/fun_get-setf-expansion.html"target="_top"><codeclass="function">GET-SETF-EXPANSION</code></a>, <codeclass="function">EXT:GET-SETF-METHOD</code> and

<codeclass="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 <ahref="http://www.lisp.org/HyperSpec/Body/fun_signal.html"target="_top"><codeclass="function">SIGNAL</code></a> an <ahref="http://www.lisp.org/HyperSpec/Body/contyp_error.html"target="_top"><codeclass="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 the <ahref="macros3.html#letf"><codeclass="function">EXT:LETF</code></a> and <ahref="macros3.html#letf"><codeclass="function">EXT:LETF*</code></a> macros.</p></div><divclass="section"lang="en"xml:lang="en"><divclass="titlepage"><div><div><h3class="title"><aid="func"></a>5.1.6. Special Operator <ahref="http://www.lisp.org/HyperSpec/Body/speope_function.html"target="_top"><codeclass="function">FUNCTION</code></a></h3></div></div></div><p><codeclass="code">(<ahref="http://www.lisp.org/HyperSpec/Body/speope_function.html"target="_top"><codeclass="function">FUNCTION</code></a><emclass="replaceable"><code>symbol</code></em>)</code> returns the local function

definition established by <ahref="http://www.lisp.org/HyperSpec/Body/speope_fletcm_scm_macrolet.html"target="_top"><codeclass="function">FLET</code></a> or <ahref="http://www.lisp.org/HyperSpec/Body/speope_fletcm_scm_macrolet.html"target="_top"><codeclass="function">LABELS</code></a>, if it exists, otherwise

<ahref="http://www.lisp.org/HyperSpec/Body/convar_t.html"target="_top"><codeclass="constant">T</code></a>. If it returns <ahref="http://www.lisp.org/HyperSpec/Body/convar_t.html"target="_top"><codeclass="constant">T</code></a>, then <codeclass="code">(<ahref="http://www.lisp.org/HyperSpec/Body/acc_symbol-function.html"target="_top"><codeclass="function">SYMBOL-FUNCTION</code></a>

tests for a <ahref="http://www.lisp.org/HyperSpec/Body/mac_define-symbol-macro.html"target="_top"><codeclass="classname">SYMBOL-MACRO</code></a>: If <emclass="replaceable"><code>symbol</code></em> is defined as a <ahref="http://www.lisp.org/HyperSpec/Body/mac_define-symbol-macro.html"target="_top"><codeclass="classname">SYMBOL-MACRO</code></a>

in the <ahref="http://www.lisp.org/HyperSpec/Body/sec_3-1-1-1.html"target="_top">global environment</a>, <codeclass="code">(<ahref="flow-dict.html#symbol-mex"><codeclass="function">EXT:SYMBOL-MACRO-EXPAND</code></a><emclass="replaceable"><code>symbol</code></em>)</code> returns two

values, <ahref="http://www.lisp.org/HyperSpec/Body/convar_t.html"target="_top"><codeclass="constant">T</code></a> and the expansion; otherwise it returns <ahref="http://www.lisp.org/HyperSpec/Body/convar_nil.html"target="_top"><codeclass="constant">NIL</code></a>.</p><p><ahref="flow-dict.html#symbol-mex"><codeclass="function">EXT:SYMBOL-MACRO-EXPAND</code></a> is a special case of <ahref="http://www.lisp.org/HyperSpec/Body/fun_macroexpa_acroexpand-1.html"target="_top"><codeclass="function">MACROEXPAND-1</code></a>. <ahref="http://www.lisp.org/HyperSpec/Body/fun_macroexpa_acroexpand-1.html"target="_top"><codeclass="function">MACROEXPAND-1</code></a>

can also test whether a symbol is defined as a <ahref="http://www.lisp.org/HyperSpec/Body/mac_define-symbol-macro.html"target="_top"><codeclass="classname">SYMBOL-MACRO</code></a> in <ahref="http://www.lisp.org/HyperSpec/Body/sec_3-1-1-3.html"target="_top">lexical environment</a>s

other than the <ahref="http://www.lisp.org/HyperSpec/Body/sec_3-1-1-1.html"target="_top">global environment</a>.</p><p>Calling <ahref="http://www.lisp.org/HyperSpec/Body/fun_boundp.html"target="_top"><codeclass="function">BOUNDP</code></a> on a symbol defined as a <ahref="http://www.lisp.org/HyperSpec/Body/mac_define-symbol-macro.html"target="_top"><codeclass="classname">SYMBOL-MACRO</code></a> returns

<ahref="http://www.lisp.org/HyperSpec/Body/convar_t.html"target="_top"><codeclass="constant">T</code></a>.</p><p>Calling <ahref="http://www.lisp.org/HyperSpec/Body/acc_symbol-value.html"target="_top"><codeclass="function">SYMBOL-VALUE</code></a> on a symbol defined as a <ahref="http://www.lisp.org/HyperSpec/Body/mac_define-symbol-macro.html"target="_top"><codeclass="classname">SYMBOL-MACRO</code></a>

returns the value of the expansion. Calling <ahref="http://www.lisp.org/HyperSpec/Body/fun_set.html"target="_top"><codeclass="function">SET</code></a> on a symbol defined

as a <ahref="http://www.lisp.org/HyperSpec/Body/mac_define-symbol-macro.html"target="_top"><codeclass="classname">SYMBOL-MACRO</code></a> calls <ahref="http://www.lisp.org/HyperSpec/Body/mac_setfcm_psetf.html"target="_top"><codeclass="function">SETF</code></a> on the expansion.</p><p>Calling <ahref="http://www.lisp.org/HyperSpec/Body/fun_makunbound.html"target="_top"><codeclass="function">MAKUNBOUND</code></a> on a symbol defined as a <ahref="http://www.lisp.org/HyperSpec/Body/mac_define-symbol-macro.html"target="_top"><codeclass="classname">SYMBOL-MACRO</code></a>

an example, consider the old ([<ahref="references.html#CLtL1"title="[CLtL1]"><spanclass="abbrev">CLtL1</span></a>]) definition of <ahref="http://www.lisp.org/HyperSpec/Body/fun_gensym.html"target="_top"><codeclass="function">GENSYM</code></a>:</p><preclass="programlisting">

This extension is disabled by <ahref="clisp.html#opt-ansi"class="olink"><codeclass="option">-ansi</code></a> and by setting <ahref="ansi.html"class="olink"><codeclass="varname">CUSTOM:*ANSI*</code></a> to <ahref="http://www.lisp.org/HyperSpec/Body/convar_t.html"target="_top"><codeclass="constant">T</code></a>,

but can be re-enabled by setting <ahref="flow-dict.html#defun-accept-spelalist"><codeclass="varname">CUSTOM:*DEFUN-ACCEPT-SPECIALIZED-LAMBDA-LIST*</code></a> explicitly.

Community

Help

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

I agree to receive quotes, newsletters and other information from sourceforge.net and its partners regarding IT services and products. I understand that I can withdraw my consent at any time. Please refer to our Privacy Policy or Contact Us for more details