Debian Codegraph @

info/gcl/set_002dmacro_002dcharacter.html

raw
1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
2 <html>
3 <!-- Created by GNU Texinfo 6.7, http://www.gnu.org/software/texinfo/ -->
4 <head>
5 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
6 <title>set-macro-character (ANSI and GNU Common Lisp Document)</title>
7
8 <meta name="description" content="set-macro-character (ANSI and GNU Common Lisp Document)">
9 <meta name="keywords" content="set-macro-character (ANSI and GNU Common Lisp Document)">
10 <meta name="resource-type" content="document">
11 <meta name="distribution" content="global">
12 <meta name="Generator" content="makeinfo">
13 <link href="index.html" rel="start" title="Top">
14 <link href="Reader-Dictionary.html" rel="up" title="Reader Dictionary">
15 <link href="set_002dsyntax_002dfrom_002dchar.html" rel="next" title="set-syntax-from-char">
16 <link href="set_002ddispatch_002dmacro_002dcharacter.html" rel="prev" title="set-dispatch-macro-character">
17 <style type="text/css">
18 <!--
19 a.summary-letter {text-decoration: none}
20 blockquote.indentedblock {margin-right: 0em}
21 div.display {margin-left: 3.2em}
22 div.example {margin-left: 3.2em}
23 div.lisp {margin-left: 3.2em}
24 kbd {font-style: oblique}
25 pre.display {font-family: inherit}
26 pre.format {font-family: inherit}
27 pre.menu-comment {font-family: serif}
28 pre.menu-preformatted {font-family: serif}
29 span.nolinebreak {white-space: nowrap}
30 span.roman {font-family: initial; font-weight: normal}
31 span.sansserif {font-family: sans-serif; font-weight: normal}
32 ul.no-bullet {list-style: none}
33 -->
34 </style>
35
36
37 </head>
38
39 <body lang="en">
40 <span id="set_002dmacro_002dcharacter"></span><div class="header">
41 <p>
42 Next: <a href="set_002dsyntax_002dfrom_002dchar.html" accesskey="n" rel="next">set-syntax-from-char</a>, Previous: <a href="set_002ddispatch_002dmacro_002dcharacter.html" accesskey="p" rel="prev">set-dispatch-macro-character</a>, Up: <a href="Reader-Dictionary.html" accesskey="u" rel="up">Reader Dictionary</a> &nbsp; </p>
43 </div>
44 <hr>
45 <span id="set_002dmacro_002dcharacter_002c-get_002dmacro_002dcharacter-_005bFunction_005d"></span><h4 class="subsection">23.2.10 set-macro-character, get-macro-character [Function]</h4>
46
47 <p><code>get-macro-character</code> <i>char <span class="roman">&amp;optional</span> readtable</i> &rArr; <i>function, non-terminating-p</i>
48 </p>
49 <p><code>set-macro-character</code> <i>char new-function <span class="roman">&amp;optional</span> non-terminating-p readtable</i> &rArr; <i><b>t</b></i>
50 </p>
51 <span id="Arguments-and-Values_003a_003a-479"></span><h4 class="subsubheading">Arguments and Values::</h4>
52
53 <p><i>char</i>&mdash;a <i>character</i>.
54 </p>
55 <p><i>non-terminating-p</i>&mdash;a <i>generalized boolean</i>.
56 The default is <i>false</i>.
57 </p>
58 <p><i>readtable</i>&mdash;a <i>readtable designator</i>.
59 </p>
60 <p>The default is the <i>current readtable</i>.
61 </p>
62 <p><i>function</i>&mdash;<b>nil</b>,
63 or a <i>designator</i> for a <i>function</i> of two <i>arguments</i>.
64 </p>
65 <p><i>new-function</i>&mdash;a <i>function designator</i>.
66 </p>
67 <span id="Description_003a_003a-629"></span><h4 class="subsubheading">Description::</h4>
68
69 <p><b>get-macro-character</b> returns as its <i>primary value</i>, <i>function</i>,
70 the <i>reader macro function</i> associated with <i>char</i> in <i>readtable</i> (if any),
71 or else <b>nil</b> if <i>char</i> is not a <i>macro character</i> in <i>readtable</i>.
72 The <i>secondary value</i>, <i>non-terminating-p</i>, is <i>true</i>
73 if <i>char</i> is a <i>non-terminating</i> <i>macro character</i>;
74 otherwise, it is <i>false</i>.
75 </p>
76 <p><b>set-macro-character</b> causes <i>char</i> to be a <i>macro character</i>
77 associated with the <i>reader macro function</i> <i>new-function</i>
78 (or the <i>designator</i> for <i>new-function</i>) in <i>readtable</i>.
79 If <i>non-terminating-p</i> is <i>true</i>,
80 <i>char</i> becomes a <i>non-terminating</i> <i>macro character</i>;
81 otherwise it becomes a <i>terminating</i> <i>macro character</i>.
82 </p>
83 <span id="Examples_003a_003a-450"></span><h4 class="subsubheading">Examples::</h4>
84
85 <div class="example">
86 <pre class="example"> (get-macro-character #\{) &rArr; NIL, <i>false</i>
87 (not (get-macro-character #\;)) &rArr; <i>false</i>
88 </pre></div>
89
90 <p>The following is a possible definition for the <i>single-quote</i> <i>reader macro</i>
91 in <i>standard syntax</i>:
92 </p>
93 <div class="example">
94 <pre class="example"> (defun single-quote-reader (stream char)
95 (declare (ignore char))
96 (list 'quote (read stream t nil t))) &rArr; SINGLE-QUOTE-READER
97 (set-macro-character #\' #'single-quote-reader) &rArr; T
98 </pre></div>
99
100 <p>Here <tt>single-quote-reader</tt> reads an <i>object</i> following the <i>single-quote</i>
101 and returns a <i>list</i> of <b>quote</b> and that <i>object</i>.
102 The <i>char</i> argument is ignored.
103 </p>
104 <p>The following is a possible definition for the <i>semicolon</i> <i>reader macro</i>
105 in <i>standard syntax</i>:
106 </p>
107 <div class="example">
108 <pre class="example"> (defun semicolon-reader (stream char)
109 (declare (ignore char))
110 ;; First swallow the rest of the current input line.
111 ;; End-of-file is acceptable for terminating the comment.
112 (do () ((char= (read-char stream nil #\Newline t) #\Newline)))
113 ;; Return zero values.
114 (values)) &rArr; SEMICOLON-READER
115 (set-macro-character #\; #'semicolon-reader) &rArr; T
116 </pre></div>
117
118 <span id="Side-Effects_003a_003a-79"></span><h4 class="subsubheading">Side Effects::</h4>
119
120 <p>The <i>readtable</i> is modified.
121 </p>
122 <span id="See-Also_003a_003a-512"></span><h4 class="subsubheading">See Also::</h4>
123
124 <p><a href="readtable.html">readtable</a>
125 </p>
126 <hr>
127 <div class="header">
128 <p>
129 Next: <a href="set_002dsyntax_002dfrom_002dchar.html" accesskey="n" rel="next">set-syntax-from-char</a>, Previous: <a href="set_002ddispatch_002dmacro_002dcharacter.html" accesskey="p" rel="prev">set-dispatch-macro-character</a>, Up: <a href="Reader-Dictionary.html" accesskey="u" rel="up">Reader Dictionary</a> &nbsp; </p>
130 </div>
131
132
133
134 </body>
135 </html>