Debian Codegraph @

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

raw
1 <html><head><title>XLISP :isnew</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>:isa</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>message selector</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>xlobj.c</nobr></td>
31 </tr>
32 </tbody></table></p>
33
34 <h2>Syntax</h2>
35
36 <p><div class="box">
37
38 <dl>
39 <dt>(<a href="send.htm">send</a> <i>object</i> :isa <i>class</i>) - test if object inherits from class</dt>
40 <dd>returns - <a href="../reference/t.htm">&nbsp;T&nbsp;</a> if object
41 is an instance of class or a subclass of class, otherwise
42 <a href="../reference/nil.htm">NIL</a><br><br></dd>
43 </dl>
44
45 </div></p>
46
47 <h2>Description</h2>
48
49 <p>The ':isa' message selector tests if an object inherits from a class.</p>
50
51 <h2>Examples</h2>
52
53 <pre class="example">
54 (setq a-class (send class :new '(state))) <font color="#008844">; create a new class A-CLASS with STATE</font>
55
56 (send a-class :answer :isnew '() <font color="#008844">; set up initialization</font>
57 '((setq state nil) self))
58
59 (send a-class :answer :set-it '(value) <font color="#008844">; create :SET-IT message</font>
60 '((setq state value)))
61
62 (setq an-obj (send a-class :new)) <font color="#008844">; create AN-OBJ out of A-CLASS</font>
63
64 (send an-obj :show) <font color="#008844">; returns object - STATE = NIL</font>
65
66 (send an-obj :set-it 5) <font color="#008844">; STATE is set to 5</font>
67 (send an-obj :show) <font color="#008844">; returns object - STATE = 5</font>
68
69 (SEND an-obj :ISNEW) <font color="#008844">; re-initialize AN-OBJ</font>
70 (send an-obj :show) <font color="#008844">; returns object - STATE = NIL</font>
71 </pre>
72
73 <p><nobr>&nbsp;&nbsp;<a href="#top">Back to Top</nobr></a></p>
74
75 <hr>
76
77 <a href="../start.htm">Nyquist / XLISP 2.0</a>&nbsp; -&nbsp;
78 <a href="../manual/contents.htm">Contents</a> |
79 <a href="../tutorials/tutorials.htm">Tutorials</a> |
80 <a href="../examples/examples.htm">Examples</a> |
81 <a href="reference-index.htm">Reference</a>
82
83 </body></html>