430 lines
No EOL
9 KiB
HTML
430 lines
No EOL
9 KiB
HTML
<!DOCTYPE HTML>
|
|
<HTML LANG="en-us"
|
|
><HEAD
|
|
><TITLE
|
|
>set-dispatch-macro-character, get-dispatch-macro-character | Common Lisp Nova Spec</TITLE
|
|
><META CHARSET="US-ASCII"
|
|
><LINK REL="canonical" HREF="f_set-dispatch-macro-character.html"
|
|
><LINK REL="next" HREF="f_set-macro-character.html" TYPE="text/html" TITLE="set-macro-character, get-macro-character"
|
|
><LINK REL="prev" HREF="f_readtablep.html" TYPE="text/html" TITLE="readtablep"
|
|
><LINK REL="up" HREF="23_2_Reader_Dictionary.html" TYPE="text/html" TITLE="23.2 Reader Dictionary"
|
|
><LINK REL="start" HREF="index.html" TYPE="text/html" TITLE="Common Lisp Nova Spec"
|
|
><META NAME="VIEWPORT" CONTENT="width=device-width, initial-scale=1.0"
|
|
><LINK REL="STYLESHEET" HREF="dpans.css%3F3909942064.css"
|
|
><SCRIPT SRC="dpans.js%3F3909942064"
|
|
></SCRIPT
|
|
><SCRIPT SRC="apropos.js%3F3909942064"
|
|
></SCRIPT
|
|
></HEAD
|
|
><BODY
|
|
><DIV
|
|
><DIV CLASS="topnav"
|
|
><DIV CLASS="breadcrumb"
|
|
><SPAN CLASS="breadcrumb-item"
|
|
><A HREF="index.html"
|
|
>Common Lisp Nova Spec</A
|
|
></SPAN
|
|
> <SPAN CLASS="breadcrumb-item"
|
|
>→ <A HREF="23_Reader.html"
|
|
>23. Reader</A
|
|
></SPAN
|
|
> <SPAN CLASS="breadcrumb-item"
|
|
>→ <A HREF="23_2_Reader_Dictionary.html"
|
|
>23.2 Reader Dictionary</A
|
|
></SPAN
|
|
> <SPAN CLASS="breadcrumb-item"
|
|
>→ <A HREF="f_set-dispatch-macro-character.html"
|
|
>set-dispatch-macro-character, get-dispatch-macro-character</A
|
|
></SPAN
|
|
></DIV
|
|
><DIV CLASS="apropos"
|
|
><DIV CLASS="apropos-io"
|
|
><A HREF="f_readtablep.html" CLASS="prev"
|
|
>←</A
|
|
><SPAN ID="apropos-label"
|
|
>Apropos </SPAN
|
|
><INPUT ID="apropos" AUTOFOCUS="AUTOFOCUS" PLACEHOLDER="Type here to search" ONINPUT="aproposInput(this);" ONKEYUP="aproposKeyup(event);" ONCHANGE="aproposChange(this);" ONFOCUS="aproposFocus(this);" ONFOCUSOUT="aproposFocusout(this);"
|
|
><A HREF="f_set-macro-character.html" CLASS="next"
|
|
>→</A
|
|
></DIV
|
|
><DIV ID="apropos-res"
|
|
></DIV
|
|
></DIV
|
|
></DIV
|
|
><DIV CLASS="matter"
|
|
><DIV CLASS="com"
|
|
><DIV CLASS="begincom"
|
|
><HR
|
|
><TABLE WIDTH="100%" CELLSPACING="0" CELLPADDING="0"
|
|
><TR
|
|
><TD ALIGN="LEFT" VALIGN="BASELINE" WIDTH="100%" CLASS="name"
|
|
><SPAN CLASS="idx" DATA-KIND="idxref" DATA-TERM="set-dispatch-macro-character, get-dispatch-macro-character"
|
|
></SPAN
|
|
><B
|
|
>set-dispatch-macro-character, get-dispatch-macro-character</B
|
|
></TD
|
|
><TD ALIGN="RIGHT" VALIGN="BASELINE" WIDTH="0" NOWRAP="NOWRAP" CLASS="ftype"
|
|
><I
|
|
>Function</I
|
|
></TD
|
|
></TR
|
|
></TABLE
|
|
><HR
|
|
></DIV
|
|
><UL CLASS="subtoc"
|
|
></UL
|
|
><DL
|
|
><DT
|
|
><B
|
|
>Syntax</B
|
|
></DT
|
|
><DD
|
|
><P CLASS="j"
|
|
><B
|
|
>get-dispatch-macro-character</B
|
|
> <SPAN CLASS="cmssi"
|
|
>disp-char</SPAN
|
|
> <SPAN CLASS="cmssi"
|
|
>sub-char</SPAN
|
|
> <SPAN CLASS="cmtt"
|
|
>&optional</SPAN
|
|
> <SPAN CLASS="cmssi"
|
|
>readtable</SPAN
|
|
> <SPAN CLASS="arrow"
|
|
>→</SPAN
|
|
> <SPAN CLASS="cmssi"
|
|
>function</SPAN
|
|
></P
|
|
><P CLASS="j"
|
|
><B
|
|
>set-dispatch-macro-character</B
|
|
> <SPAN CLASS="cmssi"
|
|
>disp-char</SPAN
|
|
> <SPAN CLASS="cmssi"
|
|
>sub-char</SPAN
|
|
> <SPAN CLASS="cmssi"
|
|
>new-function</SPAN
|
|
> <SPAN CLASS="cmtt"
|
|
>&optional</SPAN
|
|
> <SPAN CLASS="cmssi"
|
|
>readtable</SPAN
|
|
> <SPAN CLASS="arrow"
|
|
>→</SPAN
|
|
> <SPAN CLASS="misc"
|
|
><B
|
|
>t</B
|
|
></SPAN
|
|
></P
|
|
></DD
|
|
><DT
|
|
><B
|
|
>Arguments and Values</B
|
|
></DT
|
|
><DD
|
|
><P CLASS="j"
|
|
><VAR CLASS="param"
|
|
>disp-char</VAR
|
|
> — a <A HREF="26_1_Glossary.html#character"
|
|
><EM CLASS="term"
|
|
>character</EM
|
|
></A
|
|
>. </P
|
|
><P CLASS="j"
|
|
><VAR CLASS="param"
|
|
>sub-char</VAR
|
|
> — a <A HREF="26_1_Glossary.html#character"
|
|
><EM CLASS="term"
|
|
>character</EM
|
|
></A
|
|
>. </P
|
|
><P CLASS="j"
|
|
><VAR CLASS="param"
|
|
>readtable</VAR
|
|
> — a <A HREF="26_1_Glossary.html#readtable_designator"
|
|
><EM CLASS="term"
|
|
>readtable designator</EM
|
|
></A
|
|
>. The default is the <A HREF="26_1_Glossary.html#current_readtable"
|
|
><EM CLASS="term"
|
|
>current readtable</EM
|
|
></A
|
|
>. </P
|
|
><P CLASS="j"
|
|
><VAR CLASS="param"
|
|
>function</VAR
|
|
> — a <A HREF="26_1_Glossary.html#function_designator"
|
|
><EM CLASS="term"
|
|
>function designator</EM
|
|
></A
|
|
> or <SPAN CLASS="misc"
|
|
><B
|
|
>nil</B
|
|
></SPAN
|
|
>. </P
|
|
><P CLASS="j"
|
|
><VAR CLASS="param"
|
|
>new-function</VAR
|
|
> — a <A HREF="26_1_Glossary.html#function_designator"
|
|
><EM CLASS="term"
|
|
>function designator</EM
|
|
></A
|
|
>.</P
|
|
></DD
|
|
><DT
|
|
><B
|
|
>Description</B
|
|
></DT
|
|
><DD
|
|
><P CLASS="j"
|
|
><A HREF="f_set-dispatch-macro-character.html" CLASS="funref"
|
|
><B
|
|
>set-dispatch-macro-character</B
|
|
></A
|
|
> causes <VAR CLASS="param"
|
|
>new-function</VAR
|
|
> to be called when <VAR CLASS="param"
|
|
>disp-char</VAR
|
|
> followed by <VAR CLASS="param"
|
|
>sub-char</VAR
|
|
> is read. If <VAR CLASS="param"
|
|
>sub-char</VAR
|
|
> is a lowercase letter, it is converted to its uppercase equivalent. It is an error if <VAR CLASS="param"
|
|
>sub-char</VAR
|
|
> is one of the ten decimal digits. </P
|
|
><P CLASS="j"
|
|
><A HREF="f_set-dispatch-macro-character.html" CLASS="funref"
|
|
><B
|
|
>set-dispatch-macro-character</B
|
|
></A
|
|
> installs a <VAR CLASS="param"
|
|
>new-function</VAR
|
|
> to be called when a particular <A HREF="26_1_Glossary.html#dispatching_macro_character"
|
|
><EM CLASS="term"
|
|
>dispatching macro character</EM
|
|
></A
|
|
> pair is read. <VAR CLASS="param"
|
|
>New-function</VAR
|
|
> is installed as the dispatch function to be called when <VAR CLASS="param"
|
|
>readtable</VAR
|
|
> is in use and when <VAR CLASS="param"
|
|
>disp-char</VAR
|
|
> is followed by <VAR CLASS="param"
|
|
>sub-char</VAR
|
|
>. </P
|
|
><P CLASS="j"
|
|
>For more information about how the <VAR CLASS="param"
|
|
>new-function</VAR
|
|
> is invoked, see <A HREF="2_1_Character_Syntax.html#sec_2_1_4_4" CLASS="secref"
|
|
><SPAN CLASS="cmr"
|
|
>Section</SPAN
|
|
> <SPAN CLASS="cmr"
|
|
>2.1.4.4</SPAN
|
|
> <SPAN CLASS="cmr"
|
|
>(Macro</SPAN
|
|
> <SPAN CLASS="cmr"
|
|
>Characters)</SPAN
|
|
></A
|
|
>. </P
|
|
><P CLASS="j"
|
|
><A HREF="f_set-dispatch-macro-character.html" CLASS="funref"
|
|
><B
|
|
>get-dispatch-macro-character</B
|
|
></A
|
|
> retrieves the dispatch function associated with <VAR CLASS="param"
|
|
>disp-char</VAR
|
|
> and <VAR CLASS="param"
|
|
>sub-char</VAR
|
|
> in <VAR CLASS="param"
|
|
>readtable</VAR
|
|
>. </P
|
|
><P CLASS="j"
|
|
><A HREF="f_set-dispatch-macro-character.html" CLASS="funref"
|
|
><B
|
|
>get-dispatch-macro-character</B
|
|
></A
|
|
> returns the macro-character function for <VAR CLASS="param"
|
|
>sub-char</VAR
|
|
> under <VAR CLASS="param"
|
|
>disp-char</VAR
|
|
>, or <SPAN CLASS="misc"
|
|
><B
|
|
>nil</B
|
|
></SPAN
|
|
> if there is no function associated with <VAR CLASS="param"
|
|
>sub-char</VAR
|
|
>. If <VAR CLASS="param"
|
|
>sub-char</VAR
|
|
> is a decimal digit, <A HREF="f_set-dispatch-macro-character.html" CLASS="funref"
|
|
><B
|
|
>get-dispatch-macro-character</B
|
|
></A
|
|
> returns <SPAN CLASS="misc"
|
|
><B
|
|
>nil</B
|
|
></SPAN
|
|
>.</P
|
|
></DD
|
|
><DT
|
|
><B
|
|
>Examples</B
|
|
></DT
|
|
><DD
|
|
><PRE CLASS="screen"
|
|
>(get-dispatch-macro-character #\# #\{) <SPAN CLASS="cmsy"
|
|
><SPAN CLASS="arrow"
|
|
>→</SPAN
|
|
></SPAN
|
|
> NIL
|
|
(set-dispatch-macro-character #\# #\{ ;dispatch on #{
|
|
#'(lambda(s c n)
|
|
(let ((list (read s nil (values) t))) ;list is object after #n{
|
|
(when (consp list) ;return nth element of list
|
|
(unless (and n (< 0 n (length list))) (setq n 0))
|
|
(setq list (nth n list)))
|
|
list))) <SPAN CLASS="cmsy"
|
|
><SPAN CLASS="arrow"
|
|
>→</SPAN
|
|
></SPAN
|
|
> T
|
|
#{(1 2 3 4) <SPAN CLASS="cmsy"
|
|
><SPAN CLASS="arrow"
|
|
>→</SPAN
|
|
></SPAN
|
|
> 1
|
|
#3{(0 1 2 3) <SPAN CLASS="cmsy"
|
|
><SPAN CLASS="arrow"
|
|
>→</SPAN
|
|
></SPAN
|
|
> 3
|
|
#{123 <SPAN CLASS="cmsy"
|
|
><SPAN CLASS="arrow"
|
|
>→</SPAN
|
|
></SPAN
|
|
> 123</PRE
|
|
><P CLASS="j"
|
|
>If it is desired that <CODE CLASS="f"
|
|
>#$<I CLASS="i"
|
|
><I
|
|
>foo</I
|
|
></I
|
|
></CODE
|
|
> : as if it were <CODE CLASS="f"
|
|
>(dollars <I CLASS="i"
|
|
><I
|
|
>foo</I
|
|
></I
|
|
>)</CODE
|
|
>.</P
|
|
><PRE CLASS="screen"
|
|
>(defun |#$-reader| (stream subchar arg)
|
|
(declare (ignore subchar arg))
|
|
(list 'dollars (read stream t nil t))) <SPAN CLASS="cmsy"
|
|
><SPAN CLASS="arrow"
|
|
>→</SPAN
|
|
></SPAN
|
|
> |#$-reader|
|
|
(set-dispatch-macro-character #\# #\$ #'|#$-reader|) <SPAN CLASS="cmsy"
|
|
><SPAN CLASS="arrow"
|
|
>→</SPAN
|
|
></SPAN
|
|
> T</PRE
|
|
></DD
|
|
><DT
|
|
><B
|
|
>See Also</B
|
|
></DT
|
|
><DD
|
|
><P CLASS="j"
|
|
><A HREF="2_1_Character_Syntax.html#sec_2_1_4_4" CLASS="secref"
|
|
><SPAN CLASS="cmr"
|
|
>Section</SPAN
|
|
> <SPAN CLASS="cmr"
|
|
>2.1.4.4</SPAN
|
|
> <SPAN CLASS="cmr"
|
|
>(Macro</SPAN
|
|
> <SPAN CLASS="cmr"
|
|
>Characters)</SPAN
|
|
></A
|
|
></P
|
|
></DD
|
|
><DT
|
|
><B
|
|
>Side Effects</B
|
|
></DT
|
|
><DD
|
|
><P CLASS="j"
|
|
>The <VAR CLASS="param"
|
|
>readtable</VAR
|
|
> is modified.</P
|
|
></DD
|
|
><DT
|
|
><B
|
|
>Affected By</B
|
|
></DT
|
|
><DD
|
|
><P CLASS="j"
|
|
><A HREF="v_readtable.html" CLASS="varref"
|
|
><B
|
|
>*readtable*</B
|
|
></A
|
|
>.</P
|
|
></DD
|
|
><DT
|
|
><B
|
|
>Exceptional Situations</B
|
|
></DT
|
|
><DD
|
|
><P CLASS="j"
|
|
>For either function, an error is signaled if <VAR CLASS="param"
|
|
>disp-char</VAR
|
|
> is not a <A HREF="26_1_Glossary.html#dispatching_macro_character"
|
|
><EM CLASS="term"
|
|
>dispatching macro character</EM
|
|
></A
|
|
> in <VAR CLASS="param"
|
|
>readtable</VAR
|
|
>.</P
|
|
></DD
|
|
><DT
|
|
><B
|
|
>See Also</B
|
|
></DT
|
|
><DD
|
|
><P CLASS="j"
|
|
><A HREF="v_readtable.html" CLASS="varref"
|
|
><B
|
|
>*readtable*</B
|
|
></A
|
|
></P
|
|
></DD
|
|
><DT
|
|
><B
|
|
>Notes</B
|
|
></DT
|
|
><DD
|
|
><P CLASS="j"
|
|
>It is necessary to use <A HREF="f_make-dispatch-macro-character.html" CLASS="funref"
|
|
><B
|
|
>make-dispatch-macro-character</B
|
|
></A
|
|
> to set up the dispatch character before specifying its sub-characters.</P
|
|
></DD
|
|
></DL
|
|
></DIV
|
|
></DIV
|
|
><DIV CLASS="footer"
|
|
><DIV CLASS="btmnav"
|
|
><A HREF="f_readtablep.html" CLASS="prev"
|
|
>←</A
|
|
><A HREF="f_set-macro-character.html" CLASS="next"
|
|
>→</A
|
|
></DIV
|
|
><DIV CLASS="trail"
|
|
>Conversion to HTML copyright 2023 by Gilbert Baumann</DIV
|
|
></DIV
|
|
></DIV
|
|
><SCRIPT
|
|
>domReady();</SCRIPT
|
|
></BODY
|
|
></HTML
|
|
> |