polymorphism: better names for .binaryValue and .booleanValue are .asInteger and...
[supercollider.git] / Help / Core / Object.html
blobd228c4012f886be8e7e336851cf1b23778ed4c8f
1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
2 <html>
3 <head>
4 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
5 <meta http-equiv="Content-Style-Type" content="text/css">
6 <title></title>
7 <meta name="Generator" content="Cocoa HTML Writer">
8 <meta name="CocoaVersion" content="1038.32">
9 <style type="text/css">
10 p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica}
11 p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; min-height: 12.0px}
12 p.p3 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica; min-height: 14.0px}
13 p.p4 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica; color: #0000ee}
14 p.p5 {margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Helvetica}
15 p.p6 {margin: 0.0px 0.0px 0.0px 57.0px; text-indent: -57.0px; font: 9.0px Monaco; min-height: 12.0px}
16 p.p7 {margin: 0.0px 0.0px 0.0px 57.0px; text-indent: -57.0px; font: 12.0px Helvetica}
17 p.p8 {margin: 0.0px 0.0px 0.0px 57.0px; text-indent: -57.0px; font: 12.0px Helvetica; min-height: 14.0px}
18 p.p9 {margin: 0.0px 0.0px 0.0px 57.0px; text-indent: -57.0px; font: 9.0px Monaco}
19 p.p10 {margin: 0.0px 0.0px 0.0px 85.0px; text-indent: -85.0px; font: 12.0px Helvetica; min-height: 14.0px}
20 p.p11 {margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Helvetica; min-height: 17.0px}
21 p.p12 {margin: 0.0px 0.0px 0.0px 57.0px; text-indent: -57.0px; font: 9.0px Monaco; color: #ad140d}
22 p.p13 {margin: 0.0px 0.0px 0.0px 57.0px; text-indent: -57.0px; font: 14.0px Helvetica}
23 p.p14 {margin: 0.0px 0.0px 0.0px 57.0px; text-indent: -57.0px; font: 9.0px Monaco; color: #737373}
24 p.p15 {margin: 0.0px 0.0px 0.0px 57.0px; text-indent: -57.0px; font: 9.0px Monaco; color: #ad140d; min-height: 12.0px}
25 p.p16 {margin: 0.0px 0.0px 0.0px 57.0px; text-indent: -57.0px; font: 9.0px Monaco; color: #000000}
26 p.p17 {margin: 0.0px 0.0px 0.0px 57.0px; text-indent: -57.0px; font: 9.0px Monaco; color: #cd1713}
27 p.p18 {margin: 0.0px 0.0px 0.0px 57.0px; text-indent: -57.0px; font: 9.0px Monaco; color: #000000; min-height: 12.0px}
28 p.p19 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco}
29 p.p20 {margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco; min-height: 14.0px}
30 p.p21 {margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco}
31 p.p22 {margin: 0.0px 0.0px 0.0px 57.0px; text-indent: -57.0px; font: 9.0px Monaco; color: #001bb9}
32 span.s1 {font: 18.0px Helvetica}
33 span.s2 {color: #000000}
34 span.s3 {text-decoration: underline}
35 span.s4 {color: #001bb9}
36 span.s5 {font: 12.0px Helvetica}
37 span.s6 {color: #2c7014}
38 span.s7 {font: 9.0px Monaco}
39 span.s8 {color: #606060}
40 span.s9 {color: #ad140d}
41 span.s10 {color: #cd1713}
42 span.s11 {font: 12.0px Helvetica; color: #000000}
43 span.s12 {color: #737373}
44 span.s13 {color: #102ac3}
45 span.s14 {color: #008225}
46 span.s15 {color: #102ac2}
47 span.s16 {color: #008325}
48 span.s17 {font: 9.0px Monaco; color: #ad140d}
49 span.s18 {font: 10.0px Monaco}
50 span.Apple-tab-span {white-space:pre}
51 </style>
52 </head>
53 <body>
54 <p class="p1"><span class="s1"><b>Object<span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b></span><b>abstract superclass of all objects</b><span class="s1"><b><span class="Apple-tab-span"> </span></b></span></p>
55 <p class="p2"><br></p>
56 <p class="p1">Object is the root class of all other classes. All objects are indirect instances of class Object.<span class="Apple-converted-space"> </span></p>
57 <p class="p1">We call "receiver" the object the message is sent to: receiver.method(argument).</p>
58 <p class="p3"><br></p>
59 <p class="p1">Superclass: nil (Not the Nil class, but the nil instance).</p>
60 <p class="p3"><br></p>
61 <p class="p4"><span class="s2"><b>See also:</b> <a href="Kernel/Class.html"><span class="s3">Class</span></a>, <a href="../Language/Intro-to-Objects.html"><span class="s3">Intro-to-Objects</span></a>, <a href="../Language/Classes.html"><span class="s3">Classes</span></a></span></p>
62 <p class="p3"><br></p>
63 <p class="p5"><b>Class Membership</b></p>
64 <p class="p6"><br></p>
65 <p class="p7"><b><span class="Apple-tab-span"> </span>class</b></p>
66 <p class="p8"><b><span class="Apple-tab-span"> </span></b></p>
67 <p class="p7"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>Answer the class of the receiver.</p>
68 <p class="p8"><br></p>
69 <p class="p9"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>5.class;</p>
70 <p class="p6"><br></p>
71 <p class="p7"><b><span class="Apple-tab-span"> </span>respondsTo(selector)</b></p>
72 <p class="p8"><b><span class="Apple-tab-span"> </span></b></p>
73 <p class="p7"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>Answer a Boolean whether the receiver understands the message selector. <b>selector</b> must be a <a href="Symbol.html"><span class="s4">Symbol</span></a>.</p>
74 <p class="p8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
75 <p class="p9"><span class="s5"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span>5.respondsTo(<span class="s6">'+'</span>);</p>
76 <p class="p6"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
77 <p class="p7"><b><span class="Apple-tab-span"> </span>isKindOf(aClass)</b></p>
78 <p class="p8"><b><span class="Apple-tab-span"> </span></b></p>
79 <p class="p7"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>Answer a <a href="Boolean.html"><span class="s4">Boolean</span></a> indicationg whether the receiver is a direct or indirect instance of <b>aClass</b>. Use of this message in code must be questioned, because it often indicates a missed opportunity to exploit object polymorphism.</p>
80 <p class="p8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
81 <p class="p9"><span class="s5"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span>5.isKindOf(<span class="s4">Magnitude</span>);</p>
82 <p class="p6"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
83 <p class="p7"><b><span class="Apple-tab-span"> </span>isMemberOf(aClass)</b></p>
84 <p class="p8"><b><span class="Apple-tab-span"> </span></b></p>
85 <p class="p7"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>Answer a Boolean whether the receiver is a direct instance of <b>aClass</b>. Use of this message in code is almost always a design mistake.</p>
86 <p class="p8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
87 <p class="p9"><span class="s5"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span>5.isMemberOf(<span class="s4">Magnitude</span>);</p>
88 <p class="p10"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
89 <p class="p5"><b>Accessing</b></p>
90 <p class="p6"><br></p>
91 <p class="p7"><b><span class="Apple-tab-span"> </span>size</b></p>
92 <p class="p8"><b><span class="Apple-tab-span"> </span></b></p>
93 <p class="p7"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>Different classes interpret this message differently.<span class="Apple-converted-space">  </span>Object always returns 0.</p>
94 <p class="p8"><br></p>
95 <p class="p8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
96 <p class="p11"><br></p>
97 <p class="p5"><b>Copying</b></p>
98 <p class="p6"><br></p>
99 <p class="p7"><b><span class="Apple-tab-span"> </span>copy</b></p>
100 <p class="p8"><b><span class="Apple-tab-span"> </span></b></p>
101 <p class="p7"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>Make a copy of the receiver. The implementation of this message depends on the object's class.<span class="Apple-converted-space">  </span>In class Object, copy calls shallowCopy.</p>
102 <p class="p6"><br></p>
103 <p class="p7"><b><span class="Apple-tab-span"> </span>shallowCopy</b></p>
104 <p class="p8"><b><span class="Apple-tab-span"> </span></b></p>
105 <p class="p7"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>Makes a copy of the object. The copy's named and indexed instance variables refer to the same objects as the receiver.</p>
106 <p class="p6"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
107 <p class="p7"><b><span class="Apple-tab-span"> </span>deepCopy</b></p>
108 <p class="p8"><b><span class="Apple-tab-span"> </span></b></p>
109 <p class="p7"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>Recursively copies the object and all of the objects contained in the instance variables, and so on down the structure. This method works with cyclic graphs.</p>
110 <p class="p8"><span class="Apple-tab-span"> </span></p>
111 <p class="p7"><span class="Apple-tab-span"> </span><b>copyImmutable</b></p>
112 <p class="p8"><b><span class="Apple-tab-span"> </span></b></p>
113 <p class="p7"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>If object is immutable then return a shallow copy, else return receiver.</p>
114 <p class="p6"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
115 <p class="p6"><br></p>
116 <p class="p6"><br></p>
117 <p class="p5"><b>Conversion</b></p>
118 <p class="p6"><br></p>
119 <p class="p1"><span class="Apple-converted-space"> </span>To convert an object of a certain <a href="Kernel/Class.html"><span class="s4">Class</span></a> into a similar, Object provides a number of methods.</p>
120 <p class="p2"><br></p>
121 <p class="p7"><b><span class="Apple-tab-span"> </span>as(class)</b></p>
122 <p class="p8"><b><span class="Apple-tab-span"> </span></b></p>
123 <p class="p7"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>Returns a similar new Object of a different class.</p>
124 <p class="p8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
125 <p class="p9"><span class="s5"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span>[1, 2, 3].as(<span class="s4">Set</span>);</p>
126 <p class="p9"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="s4">Pwhite</span>(0.0, 1.0, 10).as(<span class="s4">Set</span>);</p>
127 <p class="p6"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
128 <p class="p7"><span class="s7"><span class="Apple-tab-span"> </span></span><b>asArray</b></p>
129 <p class="p8"><b><span class="Apple-tab-span"> </span></b></p>
130 <p class="p7"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>Returns an Array with the receiver, unless it is an <a href="../Collections/Array.html"><span class="s4">Array</span></a> already.<span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
131 <p class="p8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
132 <p class="p9"><span class="s5"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span>[1, 2, 3].asArray;<span class="Apple-tab-span"> </span></p>
133 <p class="p9"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>5.asArray;</p>
134 <p class="p6"><span class="Apple-tab-span"> </span></p>
135 <p class="p7"><span class="s7"><span class="Apple-tab-span"> </span></span><b>asCompileString</b></p>
136 <p class="p8"><b><span class="Apple-tab-span"> </span></b></p>
137 <p class="p7"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>Returns a String that can be interpreted to reconstruct a copy of the receiver.</p>
138 <p class="p7"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>For the complementary method, see <a href="../Collections/String.html"><span class="s4">String</span></a> interpret<span class="Apple-tab-span"> </span>.</p>
139 <p class="p8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
140 <p class="p9"><span class="s5"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span>a = { 10.do { 10.postln } };</p>
141 <p class="p9"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>a.asCompileString.postcs;</p>
142 <p class="p9"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>a.postcs;</p>
143 <p class="p6"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
144 <p class="p7"><span class="s7"><span class="Apple-tab-span"> </span></span><b>cs</b></p>
145 <p class="p7"><b><span class="Apple-tab-span"> </span></b><span class="Apple-tab-span"> </span>shortcut for <b>asCompileString</b></p>
146 <p class="p9"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>{ 10.do { 10.postln } }.cs;</p>
147 <p class="p6"><br></p>
148 <p class="p6"><br></p>
149 <p class="p5"><b>Archiving</b></p>
150 <p class="p6"><br></p>
151 <p class="p1">Object implements methods for writing and retrieving objects from disk. Note that you cannot archive instances of <a href="Kernel/Thread.html"><span class="s4">Thread</span></a> and its subclasses (i.e. <a href="Kernel/Routine.html"><span class="s4">Routine</span></a>), or open Functions (i.e. a <a href="Kernel/Function.html"><span class="s4">Function</span></a> which refers to variables from outside its own scope).</p>
152 <p class="p2"><br></p>
153 <p class="p7"><b><span class="Apple-tab-span"> </span>writeArchive(pathname)</b></p>
154 <p class="p8"><b><span class="Apple-tab-span"> </span></b></p>
155 <p class="p7"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>Write an object to disk as a text archive. <b>pathname</b> is a <a href="../Collections/String.html"><span class="s4">String</span></a> containing the resulting file's path.</p>
156 <p class="p6"><br></p>
157 <p class="p7"><b><span class="Apple-tab-span"> </span>*readArchive(pathname)</b></p>
158 <p class="p8"><b><span class="Apple-tab-span"> </span></b></p>
159 <p class="p7"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>Read in an object from a text archive. <b>pathname</b> is a <a href="../Collections/String.html"><span class="s4">String</span></a> containing the archive file's path.</p>
160 <p class="p8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
161 <p class="p9"><span class="s5"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span>a = <span class="s4">Array</span>.fill(100, { 100.0.rand });</p>
162 <p class="p9"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>a.writeArchive(<span class="s4">PathName</span>.tmp ++ <span class="s8">"myArray"</span>);</p>
163 <p class="p9"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>b = <span class="s4">Object</span>.readArchive(<span class="s4">PathName</span>.tmp ++ <span class="s8">"myArray"</span>);</p>
164 <p class="p9"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>a == b <span class="s9">// true</span></p>
165 <p class="p6"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
166 <p class="p12"><span class="s2"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span>/////////</p>
167 <p class="p6"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
168 <p class="p12"><span class="s2"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span>// closed Function</p>
169 <p class="p9"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>(</p>
170 <p class="p9"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>f = { 1 + 2 };</p>
171 <p class="p9"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>f.writeArchive(<span class="s4">PathName</span>.tmp ++ <span class="s8">"myFunc"</span>); <span class="s9">// succeeds</span></p>
172 <p class="p9"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>)</p>
173 <p class="p12"><span class="s2"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span>// open Function</p>
174 <p class="p9"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>(</p>
175 <p class="p9"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="s4">var</span> num;</p>
176 <p class="p9"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>num = 2;</p>
177 <p class="p9"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>f = { num + 2 };</p>
178 <p class="p9"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>f.writeArchive(<span class="s4">PathName</span>.tmp ++ <span class="s8">"myFunc"</span>); <span class="s9">// fails</span></p>
179 <p class="p9"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>)</p>
180 <p class="p8"><span class="Apple-converted-space"> </span></p>
181 <p class="p13"><b>Equality and Identity</b></p>
182 <p class="p6"><br></p>
183 <p class="p7"><b><span class="Apple-tab-span"> </span>== anotherObject</b></p>
184 <p class="p8"><b><span class="Apple-tab-span"> </span></b></p>
185 <p class="p7"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>equality: </b>Answer whether the receiver equals <b>anotherObject</b>. The definition of equality depends on the class of the receiver. The default implementation in Object is to answer if the two objects are identical (see below).</p>
186 <p class="p7"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><b>Note: </b>Whenever == is overridden in a class, <b>hash</b> should be overridden as well.</p>
187 <p class="p8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
188 <p class="p9"><span class="s5"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span>5.0 == 5; <span class="s9">// true</span></p>
189 <p class="p9"><span class="s9"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span>5.0 === 5; <span class="s9">// false</span></p>
190 <p class="p9"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>a = [1, 2, 3]; b = [1, 2, 3];</p>
191 <p class="p9"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>a == b; <span class="s9">// equal</span></p>
192 <p class="p12"><span class="s2"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>a === b; </span>// not identical</p>
193 <p class="p14"><span class="s2"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span>"worth trying"<span class="s2"> == </span>"worth trying"<span class="s2">; </span><span class="s10">// equal</span></p>
194 <p class="p15"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
195 <p class="p6"><br></p>
196 <p class="p7"><b><span class="Apple-tab-span"> </span>=== anotherObject</b></p>
197 <p class="p8"><b><span class="Apple-tab-span"> </span></b></p>
198 <p class="p7"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>identity: </b>Answer whether the receiver is the exact same object as <b>anotherObject</b>.</p>
199 <p class="p8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
200 <p class="p16"><span class="s11"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span>5.0 === 5; <span class="s10">// false</span></p>
201 <p class="p14"><span class="s11"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span>"worth trying"<span class="s2"> === </span>"worth trying"<span class="s2">; </span><span class="s10">// not identical</span></p>
202 <p class="p17"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="s12">'worth trying'</span><span class="s2"> === </span><span class="s12">'worth trying'</span><span class="s2">; </span>// identical (symbols are unique)</p>
203 <p class="p8"><br></p>
204 <p class="p6"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
205 <p class="p7"><b><span class="Apple-tab-span"> </span>!= anotherObject</b></p>
206 <p class="p8"><b><span class="Apple-tab-span"> </span></b></p>
207 <p class="p7"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>non-equality: </b>Answer whether the receiver does not equal <b>anotherObject</b>. The default implementation in Object is to answer if the two objects are not identical (see below).</p>
208 <p class="p6"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
209 <p class="p7"><b><span class="Apple-tab-span"> </span>fuzzyEqual(that, precision)</b></p>
210 <p class="p8"><b><span class="Apple-tab-span"> </span></b></p>
211 <p class="p7"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>Retruns the degree of equality (in the range from 0 to 1) between two objects with regard to a given precision. Objects to compare must support max, substraction and division.</p>
212 <p class="p8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
213 <p class="p9"><span class="s5"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span>5.0.fuzzyEqual(5.0, 0.5); <span class="s9">// 1 - full equality</span></p>
214 <p class="p9"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>5.25.fuzzyEqual(5.0, 0.5); <span class="s9">// 0.5 - 50 % equality</span></p>
215 <p class="p9"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>5.9.fuzzyEqual(5.0, 0.5); <span class="s9">// 0 - no equality</span></p>
216 <p class="p8"><br></p>
217 <p class="p7"><span class="Apple-tab-span"> </span><b>compareObject(that, instVarNames)</b></p>
218 <p class="p8"><b><span class="Apple-tab-span"> </span></b></p>
219 <p class="p7"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>Tests if two Objects (of the same class) are the same in a certain respect: It returns true if <b>instVarNames</b> are equal in both. If none are given, all instance variables are tested (see also: <b>instVarHash</b>)</p>
220 <p class="p8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
221 <p class="p9"><span class="s5"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span>a = <span class="s4">Pseq</span>([1, 2, 3], <span class="s4">inf</span>); b = <span class="s4">Pseq</span>([100, 200, 300], <span class="s4">inf</span>);</p>
222 <p class="p9"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>a.compareObject(b, [<span class="s6">\repeats</span>]); <span class="s9">// true</span></p>
223 <p class="p9"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>a.compareObject(b, [<span class="s6">\list</span>]); <span class="s9">// false</span></p>
224 <p class="p8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
225 <p class="p7"><span class="Apple-tab-span"> </span><b>hash</b></p>
226 <p class="p8"><b><span class="Apple-tab-span"> </span></b></p>
227 <p class="p7"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>Answer a code used to index into a hash table. This is used by <a href="../Collections/Dictionary.html"><span class="s4">Dictionary</span></a> and <a href="../Collections/Set.html"><span class="s4">Set</span></a> and their subclasses to implement fast object lookup.<span class="Apple-converted-space">  </span>Objects which are equal == should have the same hash values. Whenever == is overridden in a class, hash should be overridden as well.</p>
228 <p class="p8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
229 <p class="p14"><span class="s2"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>a = </span>"worth trying"<span class="s2">; b = </span>"worth trying"<span class="s2">;</span></p>
230 <p class="p16"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>a.hash;</p>
231 <p class="p16"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>b.hash;</p>
232 <p class="p6"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
233 <p class="p7"><b><span class="Apple-tab-span"> </span>identityHash</b></p>
234 <p class="p8"><b><span class="Apple-tab-span"> </span></b></p>
235 <p class="p7"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>Answer a code used to index into a hash table. This method is implemented by a primitive and is not overridden. Objects which are identical === should have the same hash values.</p>
236 <p class="p8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
237 <p class="p14"><span class="s11"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span><span class="s2">a = </span>"worth trying"<span class="s2">; b = </span>"worth trying"<span class="s2">;</span></p>
238 <p class="p9"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>a.identityHash;</p>
239 <p class="p9"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>b.identityHash;</p>
240 <p class="p8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
241 <p class="p7"><span class="Apple-tab-span"> </span><b>instVarHash(instVarNames)</b></p>
242 <p class="p8"><b><span class="Apple-tab-span"> </span></b></p>
243 <p class="p7"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>Returns a combined hash value for the object's instance variables and the object's class. If none are given, all instance variables are tested (see also: <b>compareObject</b>).</p>
244 <p class="p8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
245 <p class="p16"><span class="s11"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span>a = <span class="s13">Pseq</span>([1, 2, 3], <span class="s13">inf</span>); b = <span class="s13">Pseq</span>([100, 200, 300], <span class="s13">inf</span>);</p>
246 <p class="p18"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
247 <p class="p16"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>a.instVarHash([<span class="s14">\repeats</span>]); <span class="s10">// same</span></p>
248 <p class="p16"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>b.instVarHash([<span class="s14">\repeats</span>]);</p>
249 <p class="p18"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
250 <p class="p16"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>a.instVarHash([<span class="s14">\list</span>]); <span class="s10">// different</span></p>
251 <p class="p16"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>b.instVarHash([<span class="s14">\list</span>]);</p>
252 <p class="p18"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
253 <p class="p9"><span class="s2"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span>a = <span class="s15">Pseq</span>([1, 2, 3], <span class="s15">inf</span>); b = <span class="s15">Prand</span>([1, 2, 3], <span class="s15">inf</span>);</p>
254 <p class="p9"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>a.instVarHash([<span class="s16">\list</span>]); <span class="s10">// different</span></p>
255 <p class="p9"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>b.instVarHash([<span class="s16">\list</span>]);</p>
256 <p class="p8"><br></p>
257 <p class="p8"><br></p>
258 <p class="p5"><b>Testing</b></p>
259 <p class="p6"><br></p>
260 <p class="p7"><b><span class="Apple-tab-span"> </span>isNil</b></p>
261 <p class="p8"><b><span class="Apple-tab-span"> </span></b></p>
262 <p class="p7"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>Answer a <a href="Boolean.html"><span class="s4">Boolean</span></a> indicating whether the receiver is nil.</p>
263 <p class="p6"><br></p>
264 <p class="p7"><b><span class="Apple-tab-span"> </span>notNil</b></p>
265 <p class="p8"><b><span class="Apple-tab-span"> </span></b></p>
266 <p class="p7"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>Answer a <a href="Boolean.html"><span class="s4">Boolean</span></a> indicating whether the receiver is not nil.</p>
267 <p class="p6"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
268 <p class="p7"><b><span class="Apple-tab-span"> </span>isNumber</b></p>
269 <p class="p8"><b><span class="Apple-tab-span"> </span></b></p>
270 <p class="p7"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>Answer a <a href="Boolean.html"><span class="s4">Boolean</span></a> indicating whether the receiver is an instance of <a href="../Math/Number.html"><span class="s4">Number</span></a>.</p>
271 <p class="p6"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
272 <p class="p7"><b><span class="Apple-tab-span"> </span>isInteger</b></p>
273 <p class="p8"><b><span class="Apple-tab-span"> </span></b></p>
274 <p class="p7"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>Answer a <a href="Boolean.html"><span class="s4">Boolean</span></a> indicating whether the receiver is an instance of <a href="../Math/Integer.html"><span class="s4">Integer</span></a>.</p>
275 <p class="p8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
276 <p class="p7"><span class="Apple-tab-span"> </span><b>isFloat</b></p>
277 <p class="p8"><b><span class="Apple-tab-span"> </span></b></p>
278 <p class="p7"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>Answer a <a href="Boolean.html"><span class="s4">Boolean</span></a> indicating whether the receiver is an instance of <a href="../Math/Float.html"><span class="s4">Float</span></a>.</p>
279 <p class="p8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
280 <p class="p7"><span class="Apple-tab-span"> </span><b>? anObject</b></p>
281 <p class="p8"><b><span class="Apple-tab-span"> </span></b></p>
282 <p class="p7"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>If the receiver is nil then answer <b>anObject</b>, otherwise answer the receiver.</p>
283 <p class="p8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
284 <p class="p7"><span class="Apple-tab-span"> </span><b>?? aFunction</b></p>
285 <p class="p8"><b><span class="Apple-tab-span"> </span></b></p>
286 <p class="p7"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>If the receiver is nil, evaluate the <a href="Kernel/Function.html"><span class="s4">Function</span></a> and return the result.</p>
287 <p class="p8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
288 <p class="p7"><span class="Apple-tab-span"> </span><b>pointsTo(obj)</b></p>
289 <p class="p8"><b><span class="Apple-tab-span"> </span></b></p>
290 <p class="p7"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>Returns true if receiver has a direct reference to obj.</p>
291 <p class="p6"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
292 <p class="p9"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>a = 9;</p>
293 <p class="p9"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>b = [1, a, 6, 8];</p>
294 <p class="p9"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>c = [1, b, 5];</p>
295 <p class="p9"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>c.pointsTo(b); <span class="s9">// true</span></p>
296 <p class="p9"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>c.pointsTo(a); <span class="s9">// false</span></p>
297 <p class="p15"><span class="Apple-tab-span"> </span></p>
298 <p class="p7"><span class="s17"><span class="Apple-tab-span"> </span></span><b>mutable</b></p>
299 <p class="p8"><b><span class="Apple-tab-span"> </span></b></p>
300 <p class="p7"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>Returns true if receiver is mutable.</p>
301 <p class="p8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
302 <p class="p9"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>a = #[1, 2, 3]; b = [1, 2, 3];</p>
303 <p class="p9"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>a.mutable; <span class="s9">// false</span></p>
304 <p class="p9"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>b.mutable; <span class="s9">// true</span></p>
305 <p class="p8"><br></p>
306 <p class="p7"><span class="s17"><span class="Apple-tab-span"> </span></span><b>frozen</b></p>
307 <p class="p8"><b><span class="Apple-tab-span"> </span></b></p>
308 <p class="p7"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>Returns true if receiver is frozen.<span class="Apple-tab-span"> </span></p>
309 <p class="p6"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
310 <p class="p7"><b><span class="Apple-tab-span"> </span>switch(cases)</b></p>
311 <p class="p8"><b><span class="Apple-tab-span"> </span></b></p>
312 <p class="p7"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>Object implements a switch<b> </b>method which allows for conditional evaluation with multiple cases. These are implemented as pairs of test objects (tested using if this == test.value) and corresponding functions to be evaluated if true. In order for switch to be inlined (and thus be as efficient as nested if statements) the matching values must be literal Integers, Floats, Chars, Symbols and the functions must have no variables or arguments.</p>
313 <p class="p8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
314 <p class="p7"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="s7">(</span></p>
315 <p class="p19"><span class="s4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>var</span> x, z;</p>
316 <p class="p19"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>z = [0, 1, 1.1, 1.3, 1.5, 2];</p>
317 <p class="p19"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>switch (z.choose.postln,</p>
318 <p class="p19"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>1, <span class="Apple-converted-space">  </span>{ <span class="s6">\no</span> },</p>
319 <p class="p19"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>1.1, { <span class="s6">\wrong</span> },</p>
320 <p class="p19"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>1.3, { <span class="s6">\wrong</span> },</p>
321 <p class="p19"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>1.5, { <span class="s6">\wrong</span> },</p>
322 <p class="p19"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>2, <span class="Apple-converted-space">  </span>{ <span class="s6">\wrong</span> },</p>
323 <p class="p19"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>0, <span class="Apple-converted-space">  </span>{ <span class="s6">\true</span> }</p>
324 <p class="p19"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>).postln;</p>
325 <p class="p19"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>)</p>
326 <p class="p2"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
327 <p class="p1"><span class="s18"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span>or:</p>
328 <p class="p20"><span class="s5"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
329 <p class="p21"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="s7">(</span></p>
330 <p class="p19"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="s4">var</span> x, z;</p>
331 <p class="p19"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>z = [0, 1, 1.1, 1.3, 1.5, 2];</p>
332 <p class="p19"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>x = switch (z.choose)</p>
333 <p class="p19"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>{1} <span class="Apple-converted-space">  </span>{ <span class="s6">\no</span> }</p>
334 <p class="p19"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>{1.1} { <span class="s6">\wrong</span> }</p>
335 <p class="p19"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>{1.3} { <span class="s6">\wrong</span> }</p>
336 <p class="p19"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>{1.5} { <span class="s6">\wrong</span> }</p>
337 <p class="p19"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>{2} <span class="Apple-converted-space">  </span>{ <span class="s6">\wrong</span> }</p>
338 <p class="p19"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>{0} <span class="Apple-converted-space">  </span>{ <span class="s6">\true</span> };</p>
339 <p class="p19"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>x.postln;</p>
340 <p class="p19"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>)</p>
341 <p class="p2"><br></p>
342 <p class="p5"><b>Messaging</b></p>
343 <p class="p11"><br></p>
344 <p class="p1">Instead of directly sending a method to an object, a method may be invoked given a method selector only (a <a href="Symbol.html"><span class="s4">Symbol</span></a>). The other arguments may be provided by passing them directly, from an environment. If it si not known whether the receiver implements the metod, tryPerform only sends if it does, and superPerform invokes the method of the superclass.</p>
345 <p class="p11"><br></p>
346 <p class="p2"><br></p>
347 <p class="p7"><b><span class="Apple-tab-span"> </span>perform(selector ... args)</b></p>
348 <p class="p8"><b><span class="Apple-tab-span"> </span></b></p>
349 <p class="p7"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>The selector argument must be a <a href="Symbol.html"><span class="s4">Symbol</span></a>. Sends the method named by the selector with the given arguments to the receiver.</p>
350 <p class="p6"><br></p>
351 <p class="p7"><b><span class="Apple-tab-span"> </span>performList(selector, [args])</b></p>
352 <p class="p8"><b><span class="Apple-tab-span"> </span></b></p>
353 <p class="p7"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>The selector argument must be a <a href="Symbol.html"><span class="s4">Symbol</span></a>. Sends the method named by the selector with the given arguments to the receiver. If the last argument is a <a href="../Collections/List.html"><span class="s4">List</span></a> or an <a href="../Collections/Array.html"><span class="s4">Array</span></a>, then its elements are unpacked and passed as arguments.</p>
354 <p class="p8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
355 <p class="p9"><span class="s5"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span>a = { <span class="s4">|a, b, c|</span> postf(<span class="s8">"% plus % plus % is %\n"</span>, a, b, c, a + b + c); <span class="s8">""</span> };</p>
356 <p class="p9"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>a.performList(<span class="s6">\value</span>, [1, 2, 3]);</p>
357 <p class="p6"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
358 <p class="p7"><b><span class="Apple-tab-span"> </span>performMsg([args])</b></p>
359 <p class="p8"><b><span class="Apple-tab-span"> </span></b></p>
360 <p class="p7"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>The argument must be a <a href="../Collections/List.html"><span class="s4">List</span></a> or <a href="../Collections/Array.html"><span class="s4">Array</span></a> whose first element is a <a href="Symbol.html"><span class="s4">Symbol</span></a> representing a method selector. The remaining elements are unpacked and passed as arguments to the method named by the selector.</p>
361 <p class="p8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
362 <p class="p9"><span class="s5"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span>a = { <span class="s4">|a, b, c|</span> postf(<span class="s8">"% plus % plus % is %\n"</span>, a, b, c, a + b + c); <span class="s8">""</span> };</p>
363 <p class="p9"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>a.performMsg([<span class="s6">\value</span>, 1, 2, 3]);</p>
364 <p class="p8"><span class="Apple-tab-span"> </span></p>
365 <p class="p7"><span class="Apple-tab-span"> </span><b>performWithEnvir(selector, envir)</b></p>
366 <p class="p8"><b><span class="Apple-tab-span"> </span></b></p>
367 <p class="p7"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>selector: </b>A <a href="Symbol.html"><span class="s4">Symbol</span></a> representing a method selector.<span class="Apple-converted-space"> </span></p>
368 <p class="p7"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><b>envir: </b>The remaining arguments derived from the environment and passed as arguments to the method named by the selector.</p>
369 <p class="p8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
370 <p class="p9"><span class="s5"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span>a = { <span class="s4">|a, b, c|</span> postf(<span class="s8">"% plus % plus % is %\n"</span>, a, b, c, a + b + c); <span class="s8">""</span> };</p>
371 <p class="p9"><span class="s5"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span>a.performWithEnvir(<span class="s6">\value</span>, (a: 1, c: 3, d: 4, b: 2));</p>
372 <p class="p8"><span class="Apple-tab-span"> </span></p>
373 <p class="p7"><span class="Apple-tab-span"> </span><b>performKeyValuePairs(selector, pairs)</b></p>
374 <p class="p8"><b><span class="Apple-tab-span"> </span></b></p>
375 <p class="p7"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>selector: </b>A <a href="Symbol.html"><span class="s4">Symbol</span></a> representing a method selector.<span class="Apple-converted-space"> </span></p>
376 <p class="p7"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><b>pairs: </b>Array or List with key-value pairs.</p>
377 <p class="p8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
378 <p class="p9"><span class="s5"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span>a = { <span class="s4">|a, b, c|</span> postf(<span class="s8">"% plus % plus % is %\n"</span>, a, b, c, a + b + c); <span class="s8">""</span> };</p>
379 <p class="p9"><span class="s5"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span>a.performKeyValuePairs(<span class="s6">\value</span>, [<span class="s6">\a</span>, 1, <span class="s6">\b</span>, 2, <span class="s6">\c</span>, 3, <span class="s6">\d</span>, 4]);<span class="s5"><span class="Apple-tab-span"> </span></span></p>
380 <p class="p8"><span class="Apple-tab-span"> </span></p>
381 <p class="p7"><b><span class="Apple-tab-span"> </span>tryPerform(selector ... args)</b></p>
382 <p class="p8"><span class="Apple-tab-span"> </span></p>
383 <p class="p7"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>Like 'perform', but tryPerform passes the method to the receiver only if the receiver understands the method name. If the receiver doesn't implement that method, the result is nil. Note that this does not catch errors like 'try' does (see <a href="Exception.html"><span class="s4">Exception</span></a>). If the receiver does have a matching method but that method throws an error, execution will halt. But, 'tryPerform' is faster than 'try'.</p>
384 <p class="p8"><br></p>
385 <p class="p9"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>(a: 1, b: 2, c: 3).tryPerform(<span class="s6">\keysValuesDo</span>, { <span class="s4">|key, value|</span> [key, value].postln });</p>
386 <p class="p6"><br></p>
387 <p class="p12"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>// Array does not understand keysValuesDo -- result is nil</p>
388 <p class="p9"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>[1, 2, 3].tryPerform(<span class="s6">\keysValuesDo</span>, { <span class="s4">|key, value|</span> [key, value].postln });</p>
389 <p class="p6"><br></p>
390 <p class="p12"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>// Error occurs within keysValuesDo -- error is thrown back to halt execution</p>
391 <p class="p9"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>(a: 1, b: 2, c: 3).tryPerform(<span class="s6">\keysValuesDo</span>, { <span class="s4">|key, value|</span> [key, value].flippityblargh });</p>
392 <p class="p6"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
393 <p class="p6"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
394 <p class="p7"><span class="s7"><span class="Apple-tab-span"> </span></span><b>superPerform(selector, ... args)</b></p>
395 <p class="p7"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>Like perform, superPerform calls a method, however it calls the method on the superclass.</p>
396 <p class="p7"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>selector: </b>A <a href="Symbol.html"><span class="s4">Symbol</span></a> representing a method selector.<span class="Apple-converted-space"> </span></p>
397 <p class="p7"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><b>args: </b>Method arguments.</p>
398 <p class="p8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
399 <p class="p8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
400 <p class="p7"><span class="Apple-tab-span"> </span><b>superPerformList([args])</b></p>
401 <p class="p7"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>Like performList, superPerformList calls a method, however it calls the method on the superclass.</p>
402 <p class="p7"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>selector: </b>A <a href="Symbol.html"><span class="s4">Symbol</span></a> representing a method selector.<span class="Apple-converted-space"> </span></p>
403 <p class="p7"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><b>args: </b>Method arguments. If the last argument is a List or an Array, then its elements are unpacked and passed as arguments.<span class="Apple-tab-span"> </span></p>
404 <p class="p8"><span class="Apple-tab-span"> </span></p>
405 <p class="p7"><span class="s7"><span class="Apple-tab-span"> </span></span><b>multiChannelPerform(selector ... args)</b></p>
406 <p class="p8"><b><span class="Apple-tab-span"> </span></b></p>
407 <p class="p7"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>selector: </b>A <a href="Symbol.html"><span class="s4">Symbol</span></a> representing a method selector.<span class="Apple-converted-space"> </span></p>
408 <p class="p7"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><b>args: </b>Method arguments, which if they contain an array, will call the method multiple times for each sub-element.</p>
409 <p class="p9"><span class="s5"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span>a = { <span class="s4">|a, b, c|</span> format(<span class="s8">"% plus % times % is %"</span>, a, b, c, a + b * c).quote; };</p>
410 <p class="p9"><span class="s5"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span>a.multiChannelPerform(<span class="s6">\value</span>, [1, 10, 100, 1000], [2, 7, 9], [3, 7]);<span class="s5"><span class="Apple-tab-span"> </span></span></p>
411 <p class="p8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
412 <p class="p8"><br></p>
413 <p class="p8"><br></p>
414 <p class="p5"><b>Unique Methods</b></p>
415 <p class="p3"><br></p>
416 <p class="p1">Method definitions not yet implemented may be added to an Object instance.<span class="Apple-converted-space"> </span></p>
417 <p class="p2"><br></p>
418 <p class="p7"><b><span class="Apple-tab-span"> </span>addUniqueMethod(selector, function)</b></p>
419 <p class="p8"><b><span class="Apple-tab-span"> </span></b></p>
420 <p class="p7"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>Add a unique method.</p>
421 <p class="p8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
422 <p class="p9"><span class="s5"><span class="Apple-tab-span"> </span></span>a = 5;</p>
423 <p class="p9"><span class="Apple-tab-span"> </span>a.addUniqueMethod(<span class="s6">\sayHello</span>, { <span class="s4">|to|</span> <span class="s8">"hello "</span> ++ to ++ <span class="s8">", I am 5"</span> });</p>
424 <p class="p9"><span class="Apple-tab-span"> </span>a.sayHello;</p>
425 <p class="p8"><span class="Apple-tab-span"> </span></p>
426 <p class="p7"><span class="Apple-tab-span"> </span><b>removeUniqueMethod(selector)</b></p>
427 <p class="p8"><b><span class="Apple-tab-span"> </span></b></p>
428 <p class="p7"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>Remove a unique method.</p>
429 <p class="p8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
430 <p class="p9"><span class="Apple-tab-span"> </span>a.removeUniqueMethod(<span class="s6">\sayHello</span>);</p>
431 <p class="p9"><span class="Apple-tab-span"> </span>a.sayHello;</p>
432 <p class="p8"><span class="Apple-tab-span"> </span></p>
433 <p class="p7"><span class="Apple-tab-span"> </span><b>removeUniqueMethods</b></p>
434 <p class="p8"><b><span class="Apple-tab-span"> </span></b></p>
435 <p class="p7"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>Remove all unique methods of an Object.</p>
436 <p class="p3"><br></p>
437 <p class="p8"><br></p>
438 <p class="p6"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
439 <p class="p5"><b>Dependancy</b></p>
440 <p class="p2"><br></p>
441 <p class="p7"><b><span class="Apple-tab-span"> </span>addDependant(aDependant)</b></p>
442 <p class="p8"><b><span class="Apple-tab-span"> </span></b></p>
443 <p class="p7"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>Add <b>aDependant</b> to the receiver's list of dependants.</p>
444 <p class="p6"><br></p>
445 <p class="p7"><b><span class="Apple-tab-span"> </span>removeDependant(aDependant)</b></p>
446 <p class="p8"><b><span class="Apple-tab-span"> </span></b></p>
447 <p class="p7"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>Remove <b>aDependant</b> from the receiver's list of dependants.</p>
448 <p class="p6"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
449 <p class="p7"><b><span class="Apple-tab-span"> </span>dependants</b></p>
450 <p class="p8"><b><span class="Apple-tab-span"> </span></b></p>
451 <p class="p7"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>Returns an <a href="../Collections/IdentitySet.html"><span class="s4">IdentitySet</span></a> of all dependants of the receiver.</p>
452 <p class="p6"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
453 <p class="p7"><b><span class="Apple-tab-span"> </span>changed(theChanger)</b></p>
454 <p class="p8"><b><span class="Apple-tab-span"> </span></b></p>
455 <p class="p7"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>Notify the receiver's dependants that the receiver has changed. The object making the change should be passed as <b>theChanger</b>.</p>
456 <p class="p8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
457 <p class="p7"><span class="Apple-tab-span"> </span><b>update(theChanged, theChanger)</b></p>
458 <p class="p8"><b><span class="Apple-tab-span"> </span></b></p>
459 <p class="p7"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>An object upon which the receiver depends has changed. <b>theChanged</b> is the object that changed and <b>theChanger</b> is the object that made the change.</p>
460 <p class="p8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
461 <p class="p7"><span class="Apple-tab-span"> </span><b>release</b></p>
462 <p class="p8"><b><span class="Apple-tab-span"> </span></b></p>
463 <p class="p7"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>Remove all dependants of the receiver. Any object that has had dependants added must be released in order for it or its dependants to get garbage collected.</p>
464 <p class="p6"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
465 <p class="p3"><br></p>
466 <p class="p6"><br></p>
467 <p class="p5"><b>Error Support</b></p>
468 <p class="p2"><br></p>
469 <p class="p1">Object implements a number of methods which throw instances of Error. A number of methods (e.g. doesNotUnderstand) are 'private' and do not normally need to be called directly in user code. Others, such as those documented below can be useful for purposes such as object oriented design (e.g. to define an abstract interface which will be implemented in subclasses) and deprecation of methods. The reserved keyword <b>thisMethod</b> can be used to refer to the enclosing method. See also <a href="Kernel/Method.html"><span class="s4">Method</span></a> and <a href="Kernel/Function.html"><span class="s4">Function</span></a> (for exception handling).</p>
470 <p class="p8"><br></p>
471 <p class="p7"><b><span class="Apple-tab-span"> </span>throw</b></p>
472 <p class="p8"><b><span class="Apple-tab-span"> </span></b></p>
473 <p class="p7"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>Throws the receiver as an Exception, which may or may not be caught and handled by any enclosing <a href="Kernel/Function.html"><span class="s4">Function</span></a>.</p>
474 <p class="p8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
475 <p class="p7"><b><span class="Apple-tab-span"> </span>subclassResponsibility(method)</b></p>
476 <p class="p8"><b><span class="Apple-tab-span"> </span></b></p>
477 <p class="p7"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>Throws a SubclassResponsibilityError. Use this to indicate that this method should be defined in all subclasses of the receiver.</p>
478 <p class="p8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
479 <p class="p9"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>someMethod {</p>
480 <p class="p9"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="s4">this</span>.subclassResponsibility(<span class="s4">thisMethod</span>);</p>
481 <p class="p9"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>}</p>
482 <p class="p6"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
483 <p class="p7"><b><span class="Apple-tab-span"> </span>shouldNotImplement(method)</b></p>
484 <p class="p8"><b><span class="Apple-tab-span"> </span></b></p>
485 <p class="p7"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>Throws a ShouldNotImplementError. Use this to indicate that this inherited method should not be defined or used in the receiver.</p>
486 <p class="p6"><br></p>
487 <p class="p7"><b><span class="Apple-tab-span"> </span>deprecated(method, alternateMethod)</b></p>
488 <p class="p8"><b><span class="Apple-tab-span"> </span></b></p>
489 <p class="p7"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>Throws a DeprecatedError. Use this to indicate that the enclosing method has been replaced by a better one (possibly in another class), and that it will likely be removed in the future. Unlike other errors, DeprecatedError only halts execution if Error.debug == true. In all cases it posts a warning indicating that the method is deprecated and what is the recommended alternative.</p>
490 <p class="p8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
491 <p class="p9"><span class="s5"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span>foo {</p>
492 <p class="p22"><span class="s2"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span>this<span class="s2">.deprecated(</span>thisMethod<span class="s2">, </span>ThisOrSomeOtherObject<span class="s2">.findMethod(</span><span class="s6">\foo</span><span class="s2">);</span></p>
493 <p class="p12"><span class="s2"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>... </span>// execution of this method will continue unless Error.debug == true</p>
494 <p class="p9"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>}</p>
495 <p class="p6"><br></p>
496 <p class="p8"><span class="Apple-tab-span"> </span></p>
497 <p class="p8"><span class="Apple-tab-span"> </span><span class="s7"><span class="Apple-tab-span"> </span></span></p>
498 <p class="p5"><b>Printing and Introspection</b></p>
499 <p class="p2"><br></p>
500 <p class="p7"><b><span class="Apple-tab-span"> </span>post</b></p>
501 <p class="p8"><b><span class="Apple-tab-span"> </span></b></p>
502 <p class="p7"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>Print a string representation of the receiver to the post window.</p>
503 <p class="p9"><span class="s5"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span><span class="s8">"hello"</span>.post; <span class="s8">"hello"</span>.post; "";</p>
504 <p class="p6"><br></p>
505 <p class="p7"><b><span class="Apple-tab-span"> </span>postln</b></p>
506 <p class="p8"><b><span class="Apple-tab-span"> </span></b></p>
507 <p class="p7"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>Print a string representation of the receiver followed by a <b>newline</b>.</p>
508 <p class="p9"><span class="s5"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span><span class="s8">"hello"</span>.postln; <span class="s8">"hello"</span>.postln; "";</p>
509 <p class="p8"><span class="Apple-tab-span"> </span></p>
510 <p class="p7"><b><span class="Apple-tab-span"> </span>postc</b></p>
511 <p class="p8"><b><span class="Apple-tab-span"> </span></b></p>
512 <p class="p7"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>Print a string representation of the receiver preceded by <b>comments</b>.</p>
513 <p class="p9"><span class="s5"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span><span class="s8">"hello"</span>.postc; <span class="s8">"hello"</span>.postc; "";</p>
514 <p class="p6"><span class="Apple-tab-span"> </span></p>
515 <p class="p7"><span class="s7"><span class="Apple-tab-span"> </span></span><b>postcln</b></p>
516 <p class="p8"><b><span class="Apple-tab-span"> </span></b></p>
517 <p class="p7"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>Print a string representation of the receiver preceded by <b>comments</b>, followed by a <b>newline</b>.</p>
518 <p class="p9"><span class="s5"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span><span class="s8">"hello"</span>.postcln; <span class="s8">"hello"</span>.postcln; "";</p>
519 <p class="p6"><span class="Apple-tab-span"> </span></p>
520 <p class="p7"><span class="s7"><span class="Apple-tab-span"> </span></span><b>postcs</b></p>
521 <p class="p8"><b><span class="Apple-tab-span"> </span></b></p>
522 <p class="p7"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>Print the <b>compile string</b> representation of the receiver, followed by a newline.</p>
523 <p class="p9"><span class="s5"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span><span class="s8">"hello"</span>.postcs; <span class="s8">"hello"</span>.postcs; "";</p>
524 <p class="p6"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
525 <p class="p7"><b><span class="Apple-tab-span"> </span>dump</b></p>
526 <p class="p8"><b><span class="Apple-tab-span"> </span></b></p>
527 <p class="p7"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>Print a detailed low level representation of the receiver to the post window.</p>
528 <p class="p8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
529 <p class="p8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
530 <p class="p8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-converted-space"> </span></p>
531 <p class="p6"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
532 <p class="p13"><b>System Information</b></p>
533 <p class="p6"><br></p>
534 <p class="p7"><span class="s7"><span class="Apple-tab-span"> </span></span><b>gcInfo</b></p>
535 <p class="p8"><b><span class="Apple-tab-span"> </span></b></p>
536 <p class="p7"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>Posts garbage collector information in a table format.<span class="Apple-converted-space"> </span></p>
537 <p class="p7"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><b>flips</b>: the number of times the GC "flipped", i.e. when it finished incremental scanning of all reachable objects</p>
538 <p class="p7"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><b>collects</b>: the number of partial collections performed</p>
539 <p class="p7"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><b>nalloc</b>: total number of allocations</p>
540 <p class="p7"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><b>alloc</b>: total allocation in bytes</p>
541 <p class="p7"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><b>grey</b>: the number of "grey" objects, i.e. objects that point to reachable objects and are not determined to be (un)reachable yet</p>
542 <p class="p8"><br></p>
543 <p class="p7"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>Then for each size class: numer of black, white and free objects, total number of objects and the total set size.</p>
544 <p class="p8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
545 <p class="p9"><span class="s5"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span>flips 241<span class="Apple-converted-space">  </span>collects 689096 <span class="Apple-converted-space">  </span>nalloc 40173511 <span class="Apple-converted-space">  </span>alloc 322496998 <span class="Apple-converted-space">  </span>grey 346541</p>
546 <p class="p9"><span class="Apple-converted-space"> <span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span>0<span class="Apple-converted-space">  </span>bwf t sz:<span class="Apple-converted-space">    </span>882<span class="Apple-converted-space">      </span>0 368573 <span class="Apple-converted-space">  </span>369455<span class="Apple-converted-space">    </span>2955640</p>
547 <p class="p9"><span class="Apple-converted-space"> <span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span>1<span class="Apple-converted-space">  </span>bwf t sz: <span class="Apple-converted-space">  </span>6197<span class="Apple-converted-space">    </span>122 5702377 <span class="Apple-converted-space">  </span>5708696 <span class="Apple-converted-space">  </span>91339136</p>
548 <p class="p9"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>2<span class="Apple-converted-space">  </span>bwf t sz:<span class="Apple-converted-space">    </span>947<span class="Apple-converted-space">      </span>4 1500009 <span class="Apple-converted-space">  </span>1500960 <span class="Apple-converted-space">  </span>48030720</p>
549 <p class="p9"><span class="Apple-converted-space"> <span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span>3<span class="Apple-converted-space">  </span>bwf t sz: <span class="Apple-converted-space">  </span>8056<span class="Apple-converted-space">  </span>65201 301800 <span class="Apple-converted-space">  </span>375057 <span class="Apple-converted-space">  </span>24003648</p>
550 <p class="p9"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>4<span class="Apple-converted-space">  </span>bwf t sz: <span class="Apple-converted-space">  </span>4047<span class="Apple-converted-space">    </span>145 <span class="Apple-converted-space">  </span>3457 <span class="Apple-converted-space">    </span>7649 <span class="Apple-converted-space">    </span>979072</p>
551 <p class="p9"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>5<span class="Apple-converted-space">  </span>bwf t sz:<span class="Apple-converted-space">    </span>422<span class="Apple-converted-space">      </span>1<span class="Apple-converted-space">    </span>431<span class="Apple-converted-space">      </span>854 <span class="Apple-converted-space">    </span>218624</p>
552 <p class="p9"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>6<span class="Apple-converted-space">  </span>bwf t sz:<span class="Apple-converted-space">    </span>124<span class="Apple-converted-space">      </span>2 <span class="Apple-converted-space">    </span>72<span class="Apple-converted-space">      </span>198 <span class="Apple-converted-space">    </span>101376</p>
553 <p class="p9"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>7<span class="Apple-converted-space">  </span>bwf t sz: 153504<span class="Apple-converted-space">      </span>1<span class="Apple-converted-space">      </span>0 <span class="Apple-converted-space">  </span>153505 <span class="Apple-converted-space">  </span>157189120</p>
554 <p class="p9"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>8<span class="Apple-converted-space">  </span>bwf t sz: <span class="Apple-converted-space">    </span>22<span class="Apple-converted-space">      </span>0<span class="Apple-converted-space">      </span>0 <span class="Apple-converted-space">      </span>22<span class="Apple-converted-space">      </span>45056</p>
555 <p class="p9"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>9<span class="Apple-converted-space">  </span>bwf t sz:<span class="Apple-converted-space">      </span>5<span class="Apple-converted-space">      </span>0<span class="Apple-converted-space">      </span>0<span class="Apple-converted-space">        </span>5<span class="Apple-converted-space">      </span>20480</p>
556 <p class="p9"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>10<span class="Apple-converted-space">  </span>bwf t sz:<span class="Apple-converted-space">      </span>5<span class="Apple-converted-space">      </span>0<span class="Apple-converted-space">      </span>0<span class="Apple-converted-space">        </span>5<span class="Apple-converted-space">      </span>40960</p>
557 <p class="p9"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>12<span class="Apple-converted-space">  </span>bwf t sz:<span class="Apple-converted-space">      </span>2<span class="Apple-converted-space">      </span>0<span class="Apple-converted-space">      </span>0<span class="Apple-converted-space">        </span>2<span class="Apple-converted-space">      </span>65536</p>
558 <p class="p9"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>13<span class="Apple-converted-space">  </span>bwf t sz:<span class="Apple-converted-space">      </span>1<span class="Apple-converted-space">      </span>0<span class="Apple-converted-space">      </span>0<span class="Apple-converted-space">        </span>1<span class="Apple-converted-space">      </span>65536</p>
559 <p class="p9"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>19<span class="Apple-converted-space">  </span>bwf t sz:<span class="Apple-converted-space">      </span>1<span class="Apple-converted-space">      </span>0<span class="Apple-converted-space">      </span>3<span class="Apple-converted-space">        </span>4 <span class="Apple-converted-space">  </span>16777216</p>
560 <p class="p9"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>tot bwf t sz: 174215<span class="Apple-converted-space">  </span>65476 7876722 <span class="Apple-converted-space">  </span>8116413 <span class="Apple-converted-space">  </span>341832120</p>
561 <p class="p6"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
562 <p class="p8"><br></p>
563 <p class="p7"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>you can also query the amount of free memory with Object.<b>totalFree</b> and dump the currently grey objects with Object.<b>dumpGrey</b>. More memory status methods are: Object.<b>largestFreeBlock</b>, Object..<b>gcDumpSet</b>, and Object.<b>gcSanity</b>.</p>
564 <p class="p6"><span class="Apple-tab-span"> </span></p>
565 <p class="p6"><span class="Apple-tab-span"> </span></p>
566 <p class="p6"><br></p>
567 <p class="p6"><span class="Apple-tab-span"> </span></p>
568 <p class="p6"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
569 <p class="p5"><b>Iteration</b></p>
570 <p class="p6"><br></p>
571 <p class="p7"><b><span class="Apple-tab-span"> </span>do(func)</b></p>
572 <p class="p8"><b><span class="Apple-tab-span"> </span></b></p>
573 <p class="p7"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>Object evaluates the function with itself as an argument, returning the reasult. Different classes interpret this message differently. <span class="Apple-converted-space"> </span></p>
574 <p class="p8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
575 <p class="p9"><span class="s5"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span>f = { <span class="s4">|x, i|</span> [x, i].postln; };</p>
576 <p class="p9"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>[1, 2, 3].do(f); <span class="s9">// Array.do</span></p>
577 <p class="p12"><span class="s2"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>10.do(f); </span>// Integer.do</p>
578 <p class="p9"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>($Q).do(f); <span class="s9">// Object.do</span></p>
579 <p class="p15"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
580 <p class="p7"><span class="s17"><span class="Apple-tab-span"> </span></span><b>generate(func, state)</b></p>
581 <p class="p8"><b><span class="Apple-tab-span"> </span></b></p>
582 <p class="p7"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>Object iterates by the message <b>do</b>, sent to the receiver.</p>
583 <p class="p7"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>This method is used internally by list comprehensions.<span class="Apple-converted-space"> </span></p>
584 <p class="p8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
585 <p class="p7"><b><span class="Apple-tab-span"> </span>dup(n)</b></p>
586 <p class="p8"><b><span class="Apple-tab-span"> </span></b></p>
587 <p class="p7"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>Duplicates the receiver <b>n</b> times, returning an array of n copies. Different classes interpret this message differently.<span class="Apple-converted-space">  </span>The shortcut <b>"!" </b>can be used in place.</p>
588 <p class="p8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
589 <p class="p9"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>8.dup(10);</p>
590 <p class="p12"><span class="s2"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>8 ! 10; </span>// same as above</p>
591 <p class="p9"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>x = [[1], [2], [3]].dup(5);</p>
592 <p class="p12"><span class="s2"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>x[0] === x[1]; </span>// false: copies receiver.</p>
593 <p class="p12"><span class="s2"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>x[0][0] === x[1][0] </span>// true: doesn't deepCopy receiver</p>
594 <p class="p12"><span class="s2"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>{ 1.0.rand }.dup(5) </span>// other objects respond differently to dup</p>
595 <p class="p8"><br></p>
596 <p class="p8"><br></p>
597 <p class="p5"><b>Routine Support</b></p>
598 <p class="p8"><br></p>
599 <p class="p7"><span class="Apple-tab-span"> </span>Objects support the basic interface of Stream, just returning itself in respone to the following messages:</p>
600 <p class="p7"><span class="Apple-tab-span"> </span><b>next</b>, <b>reset</b>, <b>stop</b>, <b>free</b>, <b>clear</b>, <b>removedFromScheduler</b>, <b>asStream</b>.</p>
601 <p class="p8"><span class="Apple-tab-span"> </span></p>
602 <p class="p8"><span class="Apple-tab-span"> </span></p>
603 <p class="p2"><br></p>
604 <p class="p7"><b><span class="Apple-tab-span"> </span>yield</b></p>
605 <p class="p8"><b><span class="Apple-tab-span"> </span></b></p>
606 <p class="p7"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>Must be called from inside a <a href="Kernel/Routine.html"><span class="s4">Routine</span></a><b>. </b>Yields control to the calling thread. The receiver is the result passed to the calling thread's method. The result of yield will be the value passed to the Routine's <b>next</b> method the next time it is called.</p>
607 <p class="p6"><br></p>
608 <p class="p7"><b><span class="Apple-tab-span"> </span>yieldAndReset</b></p>
609 <p class="p8"><b><span class="Apple-tab-span"> </span></b></p>
610 <p class="p7"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>Must be called from inside a <a href="Kernel/Routine.html"><span class="s4">Routine</span></a><b>. </b>Yields control to the calling thread. The receiver is the result passed to the calling thread's method. The Routine is reset so that the next time it is called, it will start from the beginning. <b>yieldAndReset</b> never returns within the Routine.</p>
611 <p class="p6"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
612 <p class="p7"><b><span class="Apple-tab-span"> </span>alwaysYield</b></p>
613 <p class="p8"><b><span class="Apple-tab-span"> </span></b></p>
614 <p class="p7"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>Must be called from inside a <a href="Kernel/Routine.html"><span class="s4">Routine</span></a><b>. </b>Yields control to the calling thread. The receiver is the result passed to the calling thread's method. The Routine, when called subsequently will always yield the receiver until it is reset. alwaysYield never returns within the Routine.</p>
615 <p class="p6"><span class="Apple-tab-span"> </span></p>
616 <p class="p7"><span class="Apple-tab-span"> </span><b>embedInStream</b></p>
617 <p class="p7"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>Yields the receiver</p>
618 <p class="p8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
619 <p class="p7"><span class="s7"><span class="Apple-tab-span"> </span></span><b>idle(time)</b></p>
620 <p class="p1"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>within a routine, return values (the receiver) until this time is over. (for an example, see <a href="Kernel/Routine.html"><span class="s4">Routine</span></a>)</p>
621 <p class="p1"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>Time is measured relative to the thread's clock.</p>
622 <p class="p3"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
623 <p class="p1"><span class="Apple-tab-span"> </span><b>iter</b></p>
624 <p class="p7"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>Returns a <b>OneShotStream</b> with the receiver as return value.</p>
625 <p class="p8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
626 <p class="p7"><span class="Apple-tab-span"> </span><b>cyc(n)</b></p>
627 <p class="p7"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>Embeds the receiver in the stream n times (default: inf), each time resetting it.</p>
628 <p class="p8"><span class="Apple-tab-span"> </span></p>
629 <p class="p7"><span class="Apple-tab-span"> </span><b>fin(n)</b></p>
630 <p class="p7"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>Calls next with the receiver n times only (default: 1), yielding the result.</p>
631 <p class="p8"><span class="Apple-tab-span"> </span></p>
632 <p class="p7"><span class="Apple-tab-span"> </span><b>repeat(repeats)</b></p>
633 <p class="p7"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>Repeatedly embeds the receiver in the stream using a Pn (may thus be used for patterns and other objects alike)</p>
634 <p class="p8"><span class="Apple-tab-span"> </span></p>
635 <p class="p7"><span class="Apple-tab-span"> </span><b>loop</b></p>
636 <p class="p7"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>Indefinitely embeds the receiver in the stream<span class="Apple-converted-space"> </span></p>
637 <p class="p11"><br></p>
638 <p class="p6"><br></p>
639 <p class="p6"><br></p>
640 <p class="p5"><b>FunctionList</b></p>
641 <p class="p6"><br></p>
642 <p class="p1">The messages <b>addFunc</b>, <b>addFuncTo</b>, <b>removeFunc</b>, <b>removeFuncFrom</b> are supported by Object. See <a href="Kernel/Function.html"><span class="s4">Function</span></a>.</p>
643 <p class="p6"><br></p>
644 <p class="p6"><br></p>
645 </body>
646 </html>