| 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> - |
| 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>:isnew</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> - </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> - </nobr></td> |
| 30 |
<td width="100%"><nobr>xlobj.c</nobr></td> |
| 31 |
</tr> |
| 32 |
</tbody></table></p> |
| 33 |
|
| 34 |
<h2>Syntax</h2> |
| 35 |
|
| 36 |
<dl> |
| 37 |
<dt>(send <i>object</i> :isnew <i>args</i>)</dt> |
| 38 |
<dd><i>object</i> - an existing object<br> |
| 39 |
<i>args</i> - the arguments to be passed to the init code<br> |
| 40 |
returns - the object</dd> |
| 41 |
</dl> |
| 42 |
|
| 43 |
<dl> |
| 44 |
<dt>(send <i>class</i> :isnew <i>ivars</i> [<i>cvars</i> [<i>superclass</i>]])</dt> |
| 45 |
<dd><i>class</i> - an existing XLISP class<br> |
| 46 |
<i>ivars</i> - list of instance variables for the new class<br> |
| 47 |
<i>cvars</i> - list of class variable symbols for the new class<br> |
| 48 |
<i>superclass</i> - superclass for the new object, default is |
| 49 |
<a href="object.htm">object</a><br> |
| 50 |
returns - the new class object</dd> |
| 51 |
</dl> |
| 52 |
|
| 53 |
<h2>Description</h2> |
| 54 |
|
| 55 |
<p>The ':isnew' message selector causes an instance to run its |
| 56 |
initialization method. If an ':isnew' message is sent to a class, the class |
| 57 |
definition and state will be reset as specified in the arguments of the |
| 58 |
message.</p> |
| 59 |
|
| 60 |
<h2>Examples</h2> |
| 61 |
|
| 62 |
<pre class="example"> |
| 63 |
(setq a-class (send class :new '(state))) <font color="#008844">; create a new class A-CLASS with STATE</font> |
| 64 |
|
| 65 |
(send a-class :answer :isnew '() <font color="#008844">; set up initialization</font> |
| 66 |
'((setq state nil) self)) |
| 67 |
|
| 68 |
(send a-class :answer :set-it '(value) <font color="#008844">; create :SET-IT message</font> |
| 69 |
'((setq state value))) |
| 70 |
|
| 71 |
(setq an-obj (send a-class :new)) <font color="#008844">; create AN-OBJ out of A-CLASS</font> |
| 72 |
|
| 73 |
(send an-obj :show) <font color="#008844">; returns object - STATE = NIL</font> |
| 74 |
|
| 75 |
(send an-obj :set-it 5) <font color="#008844">; STATE is set to 5</font> |
| 76 |
(send an-obj :show) <font color="#008844">; returns object - STATE = 5</font> |
| 77 |
|
| 78 |
(SEND an-obj :ISNEW) <font color="#008844">; re-initialize AN-OBJ</font> |
| 79 |
(send an-obj :show) <font color="#008844">; returns object - STATE = NIL</font> |
| 80 |
</pre> |
| 81 |
|
| 82 |
<p>See the |
| 83 |
<a href="../manual/xlisp-man-010.htm#object-isnew">:isnew</a> |
| 84 |
message selector in the <nobr>XLISP 2.0</nobr> manual.</p> |
| 85 |
|
| 86 |
<p><nobr> <a href="#top">Back to Top</nobr></a></p> |
| 87 |
|
| 88 |
<hr> |
| 89 |
|
| 90 |
<a href="../start.htm">Nyquist / XLISP 2.0</a> - |
| 91 |
<a href="../manual/contents.htm">Contents</a> | |
| 92 |
<a href="../tutorials/tutorials.htm">Tutorials</a> | |
| 93 |
<a href="../examples/examples.htm">Examples</a> | |
| 94 |
<a href="reference-index.htm">Reference</a> |
| 95 |
|
| 96 |
</body></html> |