Debian Codegraph @

docsrc/xlisp/xlisp-doc/reference/keyword-tmacro.htm

raw
1 <html><head><title>XLISP :tmacro</title>
2
3 <link rel="stylesheet" type="text/css" href="reference.css">
4
5 </head>
6
7 <body>
8
9 <a href="../start.htm">Nyquist / XLISP 2.0</a>&nbsp; -&nbsp;
10 <a href="../manual/contents.htm">Contents</a> |
11 <a href="../tutorials/tutorials.htm">Tutorials</a> |
12 <a href="../examples/examples.htm">Examples</a> |
13 <a href="reference-index.htm">Reference</a>
14
15 <hr>
16
17 <h1>:tmacro</h1>
18
19 <hr>
20
21 <p><table cellpadding="0" cellspacing="0" style="margin-left:10px"><tbody>
22 <tr valign="top">
23 <td><nobr>Type:</nobr></td>
24 <td><nobr>&nbsp;&nbsp;-&nbsp;&nbsp;</nobr></td>
25 <td width="100%"><nobr>keyword</nobr></td>
26 </tr>
27 <tr valign="top">
28 <td><nobr>Source:</nobr></td>
29 <td><nobr>&nbsp;&nbsp;-&nbsp;&nbsp;</nobr></td>
30 <td width="100%"><nobr>xlread.c</nobr></td>
31 </tr>
32 </tbody></table></p>
33
34 <h2>Syntax</h2>
35
36 <dl>
37 <dt>(:tmacro . <i>function</i>)</dt>
38 <dd><i>function</i> - a function</dd>
39 </dl>
40
41 <h2>Description</h2>
42
43 <p>':tmacro' is an entry that is used in the
44 <a href="global-readtable.htm">*readtable*</a> system variable that contains
45 XLISP's data structures relating to the processing of characters from the
46 user [or files] and read-macro expansions. The existance of the ':tmacro'
47 keyword means that the specified character is the start of a terminal read
48 macro. For ':tmacro', the form of the
49 <a href="global-readtable.htm">*readtable*</a> entry is a dotted pair
50 like:</p>
51
52 <pre class="example">
53 (:tmacro . <font color="#008844"><i>function</i></font>)
54 </pre>
55
56 <p>The 'function' can be a built-in read-macro function or a user defined
57 lambda expression. The 'function' takes two parameters, an input stream
58 specification, and an integer that is the character value. The 'function'
59 should return <a href="nil.htm">NIL</a> if the character is
60 'white-space' or a value <a href="cons.htm">cons</a>ed with
61 <a href="nil.htm">NIL</a> to return the value. The 'function'
62 will probably read additional characters from the input stream.</p>
63
64 <h2>Examples</h2>
65
66 <pre class="example">
67 (defun look-at (table) <font color="#008844">; define a function to look in a table</font>
68 (dotimes (ch 127) <font color="#008844">; and print out any :TMACRO entries</font>
69 (prog ((entry (aref table ch)))
70 (if (and (consp entry)
71 (equal (car entry) ':TMACRO))
72 (princ (int-char ch)))))
73 (terpri))
74
75 (look-at *readtable*) <font color="#008844">; prints "'(),;`</font>
76 </pre>
77
78 <p><b>Note:</b> The system defines that the following are ':tmacro'
79 characters:</p>
80
81 <pre>
82 \ " ` , ( ) ;
83 </pre>
84
85 <p>[backslash, double quote, backquote, comma, opening parenthesis, closing
86 parenthesis, semicolon.]</p>
87
88 <p><b>Caution:</b> If you experiment with
89 <nobr><a href="global-readtable.htm">*readtable*</a> ,</nobr> it is useful
90 to save the old value in a variable, so that you can restore the system
91 state.</p>
92
93 <p>See the
94 <a href="../manual/xlisp-man-008.htm#tmacro">:tmacro</a>
95 keyword in the <nobr>XLISP 2.0</nobr> manual.</p>
96
97 <p><nobr>&nbsp;&nbsp;<a href="#top">Back to Top</nobr></a></p>
98
99 <hr>
100
101 <a href="../start.htm">Nyquist / XLISP 2.0</a>&nbsp; -&nbsp;
102 <a href="../manual/contents.htm">Contents</a> |
103 <a href="../tutorials/tutorials.htm">Tutorials</a> |
104 <a href="../examples/examples.htm">Examples</a> |
105 <a href="reference-index.htm">Reference</a>
106
107 </body></html>