author | Claus Gittinger <cg@exept.de> |
Thu, 18 Jan 2018 19:22:23 +0100 | |
changeset 22448 | 7f0bc44b4082 |
parent 22024 | 5ae2b815d111 |
child 22640 | a09d68b5a519 |
permissions | -rw-r--r-- |
1 | 1 |
" |
5 | 2 |
COPYRIGHT (c) 1988 by Claus Gittinger |
159 | 3 |
All Rights Reserved |
1 | 4 |
|
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
5471
a57eeb01c5ab
General encoding method (#encodeOn:with:)
Stefan Vogel <sv@exept.de>
parents:
4682
diff
changeset
|
12 |
"{ Package: 'stx:libbasic' }" |
a57eeb01c5ab
General encoding method (#encodeOn:with:)
Stefan Vogel <sv@exept.de>
parents:
4682
diff
changeset
|
13 |
|
18480 | 14 |
"{ NameSpace: Smalltalk }" |
15 |
||
1 | 16 |
Object subclass:#UndefinedObject |
1029
c469a63e88e2
only redefine #class/#isbehavior/#doesNotUnderstand once (if no methods are present yet)
Claus Gittinger <cg@exept.de>
parents:
695
diff
changeset
|
17 |
instanceVariableNames:'' |
2040
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
18 |
classVariableNames:'CreateMinimumProtocolInNewSubclassQuery' |
1029
c469a63e88e2
only redefine #class/#isbehavior/#doesNotUnderstand once (if no methods are present yet)
Claus Gittinger <cg@exept.de>
parents:
695
diff
changeset
|
19 |
poolDictionaries:'' |
c469a63e88e2
only redefine #class/#isbehavior/#doesNotUnderstand once (if no methods are present yet)
Claus Gittinger <cg@exept.de>
parents:
695
diff
changeset
|
20 |
category:'Kernel-Objects' |
1 | 21 |
! |
22 |
||
88 | 23 |
!UndefinedObject class methodsFor:'documentation'! |
24 |
||
25 |
copyright |
|
26 |
" |
|
27 |
COPYRIGHT (c) 1988 by Claus Gittinger |
|
159 | 28 |
All Rights Reserved |
1 | 29 |
|
88 | 30 |
This software is furnished under a license and may be used |
31 |
only in accordance with the terms of that license and with the |
|
32 |
inclusion of the above copyright notice. This software may not |
|
33 |
be provided or otherwise made available to, or used by, any |
|
34 |
other person. No title to or ownership of the software is |
|
35 |
hereby transferred. |
|
36 |
" |
|
37 |
! |
|
38 |
||
39 |
documentation |
|
40 |
" |
|
20215 | 41 |
there is only one instance of this class: nil, |
1303 | 42 |
representing an undefined or otherwise unspecified object. |
88 | 43 |
|
20215 | 44 |
All instance variables, array elements and even method/block local |
88 | 45 |
variables are initially set to nil. |
1303 | 46 |
|
20215 | 47 |
Since in Smalltalk/X (and in other smalltalks), nil is represented by |
48 |
a special pointer value (NULL), there can be only one instance of UndefinedObject, |
|
49 |
and no subclassing is possible. |
|
50 |
(to be exact: subclassing UndefinedObject is technically possible, |
|
51 |
but instances of it would not be recognized as being nil |
|
1303 | 52 |
- therefore, subclassing is blocked and an error is raised when it is tried) |
53 |
||
54 |
For advanced users: |
|
55 |
Beside the above role, nil can be subclassed (!!). |
|
56 |
This creates a class which inherits no protocol whatsoever - not even |
|
57 |
the basic interfaces as defined by the Object class. Subclasses of nil |
|
58 |
are useful if all messages send to instances should trap into the |
|
59 |
#doesNotUnderstand: method. For example, proxy objects are typically defined |
|
60 |
this way. |
|
1294 | 61 |
|
62 |
[author:] |
|
63 |
Claus Gittinger |
|
88 | 64 |
" |
65 |
! ! |
|
1 | 66 |
|
2040
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
67 |
!UndefinedObject class methodsFor:'initialization'! |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
68 |
|
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
69 |
initialize |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
70 |
CreateMinimumProtocolInNewSubclassQuery isNil ifTrue:[ |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
71 |
CreateMinimumProtocolInNewSubclassQuery := QuerySignal new. |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
72 |
CreateMinimumProtocolInNewSubclassQuery nameClass:self message:#createMinimumProtocolInNewSubclassQuery. |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
73 |
CreateMinimumProtocolInNewSubclassQuery defaultAnswer:false. |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
74 |
]. |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
75 |
|
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
76 |
" |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
77 |
UndefinedObject initialize |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
78 |
" |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
79 |
|
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
80 |
"Created: 3.1.1997 / 15:02:40 / cg" |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
81 |
"Modified: 3.1.1997 / 15:18:33 / cg" |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
82 |
! ! |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
83 |
|
1 | 84 |
!UndefinedObject class methodsFor:'instance creation'! |
85 |
||
86 |
basicNew |
|
87 |
"catch new - there MUST be only one nil in the system" |
|
88 |
||
89 |
^ nil |
|
90 |
! |
|
91 |
||
92 |
basicNew:size |
|
93 |
"catch new - there MUST be only one nil in the system" |
|
94 |
||
95 |
^ nil |
|
96 |
! ! |
|
97 |
||
2040
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
98 |
!UndefinedObject class methodsFor:'Signal constants'! |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
99 |
|
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
100 |
createMinimumProtocolInNewSubclassQuery |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
101 |
"return the signal used to ask if the minimum required protocol |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
102 |
should be created for nil subclasses. |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
103 |
By default, this is not done, however, the browser answers true |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
104 |
here, to avoid big trouble with nil subclasses which do not define |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
105 |
some methods which the inspector needs." |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
106 |
|
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
107 |
^ CreateMinimumProtocolInNewSubclassQuery |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
108 |
|
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
109 |
"Created: 3.1.1997 / 15:05:48 / cg" |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
110 |
"Modified: 3.1.1997 / 15:06:15 / cg" |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
111 |
! ! |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
112 |
|
51 | 113 |
!UndefinedObject class methodsFor:'queries'! |
114 |
||
115 |
canBeSubclassed |
|
20215 | 116 |
"return true if it is allowed to create subclasses of the receiver. |
3914 | 117 |
Return false here - since it is NOT possible for UndefinedObject. |
118 |
(due to the representation of nil as a 0-pointer)" |
|
51 | 119 |
|
120 |
^ false |
|
3914 | 121 |
|
122 |
"Modified: / 5.11.1998 / 16:11:43 / cg" |
|
2672
dc3662188b2c
added #hasImmediateInstances for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2416
diff
changeset
|
123 |
! |
dc3662188b2c
added #hasImmediateInstances for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2416
diff
changeset
|
124 |
|
dc3662188b2c
added #hasImmediateInstances for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2416
diff
changeset
|
125 |
hasImmediateInstances |
4652
8b3118a923d1
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
126 |
"return true if this class has immediate instances |
8b3118a923d1
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
127 |
i.e. if the instances are represented in the pointer itself and |
8b3118a923d1
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
128 |
no real object header/storage is used for the object. |
2672
dc3662188b2c
added #hasImmediateInstances for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2416
diff
changeset
|
129 |
Redefined from Behavior" |
dc3662188b2c
added #hasImmediateInstances for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2416
diff
changeset
|
130 |
|
dc3662188b2c
added #hasImmediateInstances for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2416
diff
changeset
|
131 |
^ true |
dc3662188b2c
added #hasImmediateInstances for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2416
diff
changeset
|
132 |
|
dc3662188b2c
added #hasImmediateInstances for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2416
diff
changeset
|
133 |
"Created: 3.6.1997 / 12:01:39 / cg" |
4321 | 134 |
! |
135 |
||
4652
8b3118a923d1
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
136 |
hasSharedInstances |
8b3118a923d1
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
137 |
"return true if this class has shared instances, that is, instances |
8b3118a923d1
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
138 |
with the same value are identical. |
4654 | 139 |
True returned here - there is only one nil." |
4652
8b3118a923d1
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
140 |
|
8b3118a923d1
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
141 |
^ true |
8b3118a923d1
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
142 |
|
8b3118a923d1
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
143 |
|
8b3118a923d1
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
144 |
! |
8b3118a923d1
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
145 |
|
4321 | 146 |
isBuiltInClass |
20215 | 147 |
"return true if this class is known by the run-time-system, |
4321 | 148 |
i.e. you cannot add/remove instance variables without recompiling |
149 |
the VM. |
|
150 |
Here, true is returned for myself, false for subclasses." |
|
151 |
||
152 |
^ self == UndefinedObject |
|
51 | 153 |
! ! |
154 |
||
5699 | 155 |
|
2416 | 156 |
!UndefinedObject methodsFor:'converting'! |
157 |
||
8305 | 158 |
asBoolean |
159 |
^ false |
|
160 |
! |
|
161 |
||
15081 | 162 |
asNilIfEmpty |
163 |
"I am nil, so answer nil" |
|
164 |
||
165 |
^ self |
|
166 |
! |
|
167 |
||
2416 | 168 |
literalArrayEncoding |
169 |
"encode myself as an array literal, from which a copy of the receiver |
|
170 |
can be reconstructed with #decodeAsLiteralArray." |
|
171 |
||
172 |
^ self |
|
173 |
||
174 |
"Created: 25.2.1997 / 19:18:47 / cg" |
|
175 |
! ! |
|
176 |
||
695 | 177 |
!UndefinedObject methodsFor:'copying'! |
178 |
||
179 |
copy |
|
180 |
"return a shallow copy of myself |
|
181 |
- since there is only one nil in the system return self" |
|
182 |
||
183 |
^ self |
|
184 |
! |
|
185 |
||
186 |
deepCopy |
|
187 |
"return a deep copy of myself |
|
188 |
- since there is only one nil in the system return self" |
|
189 |
||
190 |
^ self |
|
191 |
! |
|
192 |
||
10945 | 193 |
deepCopyUsing:aDictionary postCopySelector:postCopySelector |
695 | 194 |
"return a deep copy of myself |
8383 | 195 |
- since there is only one nil in the system, return self" |
695 | 196 |
|
197 |
^ self |
|
198 |
! |
|
199 |
||
200 |
shallowCopy |
|
201 |
"return a shallow copy of myself |
|
202 |
- since there is only one nil in the system return self" |
|
203 |
||
204 |
^ self |
|
205 |
! |
|
206 |
||
207 |
simpleDeepCopy |
|
208 |
"return a deep copy of myself |
|
209 |
- since there is only one nil in the system return self" |
|
210 |
||
211 |
^ self |
|
212 |
! ! |
|
213 |
||
22024 | 214 |
!UndefinedObject methodsFor:'debugging'! |
215 |
||
216 |
haltIfNil |
|
217 |
"halt if the receiver is nil" |
|
218 |
||
219 |
<resource: #skipInDebuggersWalkBack> |
|
220 |
||
221 |
self halt:'nil encountered' |
|
222 |
||
223 |
" |
|
224 |
3 haltIfNil |
|
225 |
nil haltIfNil |
|
226 |
" |
|
227 |
||
228 |
"Created: / 17-07-2017 / 10:52:36 / cg" |
|
229 |
! ! |
|
230 |
||
3166 | 231 |
!UndefinedObject methodsFor:'dependents access'! |
232 |
||
233 |
addDependent:someObject |
|
12968
07761a8bcc6a
comment/format in: #addDependent:
Claus Gittinger <cg@exept.de>
parents:
11821
diff
changeset
|
234 |
"raise an error here - nil may not have dependents (it never changes anyway)" |
3166 | 235 |
|
4530
793b116fef3e
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
4339
diff
changeset
|
236 |
self error:'nil may not have dependents' mayProceed:true |
793b116fef3e
error: vs. error:mayProceed:
Claus Gittinger <cg@exept.de>
parents:
4339
diff
changeset
|
237 |
|
12968
07761a8bcc6a
comment/format in: #addDependent:
Claus Gittinger <cg@exept.de>
parents:
11821
diff
changeset
|
238 |
"Modified: / 28-07-2010 / 19:20:36 / cg" |
3166 | 239 |
! |
240 |
||
3183 | 241 |
dependents |
242 |
"nil has no dependents" |
|
243 |
||
244 |
^#() |
|
245 |
! |
|
246 |
||
3464
b0009b3ea4f2
added ?? - much like ?, but sends #value to its argument.
Claus Gittinger <cg@exept.de>
parents:
3183
diff
changeset
|
247 |
release |
3166 | 248 |
"ignored here - nil has no dependents" |
3183 | 249 |
! |
3166 | 250 |
|
3464
b0009b3ea4f2
added ?? - much like ?, but sends #value to its argument.
Claus Gittinger <cg@exept.de>
parents:
3183
diff
changeset
|
251 |
removeDependent:someObject |
3183 | 252 |
"ignored here - nil has no dependents" |
3166 | 253 |
! ! |
254 |
||
1 | 255 |
!UndefinedObject methodsFor:'error catching'! |
256 |
||
257 |
basicAt:index |
|
20700 | 258 |
"catch array access - it's illegal. |
21759 | 259 |
Redefined here since basicAt: in Object omits the nil-check" |
1 | 260 |
|
261 |
^ self notIndexed |
|
21759 | 262 |
|
263 |
"Modified (comment): / 17-05-2017 / 16:36:12 / mawalch" |
|
1 | 264 |
! |
265 |
||
266 |
basicAt:index put:anObject |
|
20700 | 267 |
"catch array access - it's illegal. |
21759 | 268 |
Redefined here since basicAt:put: in Object omits the nil-check" |
1 | 269 |
|
270 |
^ self notIndexed |
|
21759 | 271 |
|
272 |
"Modified (comment): / 17-05-2017 / 16:36:17 / mawalch" |
|
1 | 273 |
! ! |
274 |
||
14678 | 275 |
|
1 | 276 |
!UndefinedObject methodsFor:'printing & storing'! |
277 |
||
63 | 278 |
printOn:aStream |
279 |
"append a printed representation of the receiver to the |
|
280 |
argument, aStream" |
|
281 |
||
282 |
aStream nextPutAll:'nil' |
|
283 |
! |
|
284 |
||
695 | 285 |
printString |
286 |
"return a string for printing myself" |
|
287 |
||
288 |
^ 'nil' |
|
289 |
! |
|
290 |
||
63 | 291 |
storeOn:aStream |
292 |
"append a printed representation of the receiver to the |
|
293 |
argument, aStream, which allows reconstruction of it" |
|
294 |
||
295 |
^ self printOn:aStream |
|
695 | 296 |
! |
297 |
||
298 |
storeString |
|
299 |
"return a string for storing myself" |
|
300 |
||
301 |
^ 'nil' |
|
1 | 302 |
! ! |
2 | 303 |
|
5557 | 304 |
!UndefinedObject methodsFor:'queries'! |
305 |
||
306 |
basicSize |
|
307 |
"return the number of indexed instvars |
|
21759 | 308 |
defined here since size in Object omits the nil-check" |
5557 | 309 |
|
310 |
^ 0 |
|
21759 | 311 |
|
312 |
"Modified (comment): / 17-05-2017 / 16:37:13 / mawalch" |
|
5557 | 313 |
! |
314 |
||
315 |
size |
|
316 |
"return the number of indexed instvars |
|
21759 | 317 |
defined here since size in Object omits the nil-check" |
20215 | 318 |
|
5557 | 319 |
^ 0 |
21759 | 320 |
|
321 |
"Modified (comment): / 17-05-2017 / 16:37:19 / mawalch" |
|
5557 | 322 |
! ! |
5471
a57eeb01c5ab
General encoding method (#encodeOn:with:)
Stefan Vogel <sv@exept.de>
parents:
4682
diff
changeset
|
323 |
|
77 | 324 |
!UndefinedObject methodsFor:'subclass creation'! |
325 |
||
2040
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
326 |
nilSubclass:action |
356 | 327 |
"common helper for subclass creation. |
20215 | 328 |
Creates a nil-superclass class. |
2040
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
329 |
If the CreateMinimumProtocolInNewSubclassQuery answers true, |
20215 | 330 |
entries for the minimum required protocol (#class, #isBehavior |
2040
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
331 |
and #doesNotUnderstand:) are also automatically created. |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
332 |
(this query is typically answered by the browser) |
356 | 333 |
These are required to avoid getting into deep trouble when |
334 |
inspecting or debugging instances of this new class. |
|
335 |
The methods get a modified source code to remind you that these |
|
336 |
methods were automatically generated." |
|
337 |
||
1461
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1303
diff
changeset
|
338 |
|newClass methodDict method| |
202 | 339 |
|
1461
dd25bb1e9973
Use methodDictionary instead of selector/method arrays.
Stefan Vogel <sv@exept.de>
parents:
1303
diff
changeset
|
340 |
Class withoutUpdatingChangesDo:[ |
2040
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
341 |
newClass := action value |
77 | 342 |
]. |
343 |
newClass notNil ifTrue:[ |
|
1029
c469a63e88e2
only redefine #class/#isbehavior/#doesNotUnderstand once (if no methods are present yet)
Claus Gittinger <cg@exept.de>
parents:
695
diff
changeset
|
344 |
newClass setSuperclass:nil. |
1803
754f9205b651
meta's superclass should be class - not Object.
Claus Gittinger <cg@exept.de>
parents:
1638
diff
changeset
|
345 |
newClass class setSuperclass:Class. |
356 | 346 |
|
21316 | 347 |
newClass hasMethods ifFalse:[ |
2040
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
348 |
Class addChangeRecordForClass:newClass. |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
349 |
|
4060
1048a3abf128
Use #query instead of #raise when invoking QuerySignals
Stefan Vogel <sv@exept.de>
parents:
3914
diff
changeset
|
350 |
CreateMinimumProtocolInNewSubclassQuery query |
2040
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
351 |
ifTrue:[ |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
352 |
" |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
353 |
copy over method objects from Object |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
354 |
and modify the source code |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
355 |
" |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
356 |
methodDict := MethodDictionary new:3. |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
357 |
#(#class #isBehavior #doesNotUnderstand:) do:[:sel| |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
358 |
method := (Object compiledMethodAt:sel) copy. |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
359 |
method source: method source , ' |
356 | 360 |
" |
361 |
*** WARNING |
|
362 |
*** |
|
363 |
*** this method has been automatically created, |
|
364 |
*** since all nil-subclasses should respond to some minimum required |
|
365 |
*** protocol. |
|
366 |
*** |
|
367 |
*** Inspection and/or debugging of instances may not be possible, |
|
368 |
*** if you remove/change this method. |
|
369 |
" |
|
370 |
'. |
|
2040
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
371 |
methodDict at:sel put:method. |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
372 |
"/ newClass addChangeRecordForMethod:method |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
373 |
]. |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
374 |
newClass methodDictionary:methodDict. |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
375 |
] |
1029
c469a63e88e2
only redefine #class/#isbehavior/#doesNotUnderstand once (if no methods are present yet)
Claus Gittinger <cg@exept.de>
parents:
695
diff
changeset
|
376 |
] |
77 | 377 |
]. |
378 |
^ newClass |
|
1029
c469a63e88e2
only redefine #class/#isbehavior/#doesNotUnderstand once (if no methods are present yet)
Claus Gittinger <cg@exept.de>
parents:
695
diff
changeset
|
379 |
|
4060
1048a3abf128
Use #query instead of #raise when invoking QuerySignals
Stefan Vogel <sv@exept.de>
parents:
3914
diff
changeset
|
380 |
"Modified: / 3.1.1997 / 15:53:21 / cg" |
1048a3abf128
Use #query instead of #raise when invoking QuerySignals
Stefan Vogel <sv@exept.de>
parents:
3914
diff
changeset
|
381 |
"Created: / 3.1.1997 / 16:00:34 / cg" |
1048a3abf128
Use #query instead of #raise when invoking QuerySignals
Stefan Vogel <sv@exept.de>
parents:
3914
diff
changeset
|
382 |
"Modified: / 18.3.1999 / 18:29:58 / stefan" |
202 | 383 |
! |
384 |
||
9256 | 385 |
subclass:nameSymbol instanceVariableNames:instVarNameString classVariableNames:classVarString poolDictionaries:pool |
20215 | 386 |
"create a new class which has nil as superclass |
9256 | 387 |
- i.e. traps into #doesNotUnderstand: for all of its messages." |
388 |
||
14678 | 389 |
"this method allows fileIn of ST/V and V'Age classes |
390 |
(which seem to have no category)" |
|
391 |
||
20215 | 392 |
^ self |
393 |
subclass:nameSymbol |
|
394 |
instanceVariableNames:instVarNameString |
|
395 |
classVariableNames:classVarString |
|
9256 | 396 |
poolDictionaries:pool |
397 |
category:(Class defaultCategoryForSTVorVAGEClasses). |
|
398 |
! |
|
399 |
||
2040
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
400 |
subclass:nameSymbol instanceVariableNames:instVarNameString classVariableNames:classVarString poolDictionaries:pool category:cat |
20215 | 401 |
"create a new class which has nil as superclass |
2040
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
402 |
- i.e. traps into #doesNotUnderstand: for all of its messages." |
202 | 403 |
|
20215 | 404 |
^ self |
2040
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
405 |
nilSubclass:[ |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
406 |
Object class |
20215 | 407 |
name:nameSymbol |
4060
1048a3abf128
Use #query instead of #raise when invoking QuerySignals
Stefan Vogel <sv@exept.de>
parents:
3914
diff
changeset
|
408 |
inEnvironment:(Class nameSpaceQuerySignal query) |
2040
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
409 |
subclassOf:self |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
410 |
instanceVariableNames:instVarNameString |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
411 |
variable:false |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
412 |
words:true |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
413 |
pointers:true |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
414 |
classVariableNames:classVarString |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
415 |
poolDictionaries:pool |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
416 |
category:cat |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
417 |
comment:nil |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
418 |
changed:true |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
419 |
] |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
420 |
|
4060
1048a3abf128
Use #query instead of #raise when invoking QuerySignals
Stefan Vogel <sv@exept.de>
parents:
3914
diff
changeset
|
421 |
"Modified: / 3.1.1997 / 16:00:39 / cg" |
1048a3abf128
Use #query instead of #raise when invoking QuerySignals
Stefan Vogel <sv@exept.de>
parents:
3914
diff
changeset
|
422 |
"Modified: / 18.3.1999 / 18:30:07 / stefan" |
695 | 423 |
! |
424 |
||
2040
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
425 |
variableByteSubclass:nameSymbol instanceVariableNames:instVarNameString classVariableNames:classVarString poolDictionaries:pool category:cat |
20215 | 426 |
"create a new class which has nil as superclass |
2040
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
427 |
- i.e. traps into #doesNotUnderstand: for all of its messages." |
695 | 428 |
|
20215 | 429 |
^ self |
2040
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
430 |
nilSubclass:[ |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
431 |
Object class |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
432 |
name:nameSymbol |
4060
1048a3abf128
Use #query instead of #raise when invoking QuerySignals
Stefan Vogel <sv@exept.de>
parents:
3914
diff
changeset
|
433 |
inEnvironment:(Class nameSpaceQuerySignal query) |
2040
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
434 |
subclassOf:self |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
435 |
instanceVariableNames:instVarNameString |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
436 |
variable:true |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
437 |
words:false |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
438 |
pointers:false |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
439 |
classVariableNames:classVarString |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
440 |
poolDictionaries:pool |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
441 |
category:cat |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
442 |
comment:nil |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
443 |
changed:true |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
444 |
] |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
445 |
|
4060
1048a3abf128
Use #query instead of #raise when invoking QuerySignals
Stefan Vogel <sv@exept.de>
parents:
3914
diff
changeset
|
446 |
"Modified: / 3.1.1997 / 16:00:42 / cg" |
1048a3abf128
Use #query instead of #raise when invoking QuerySignals
Stefan Vogel <sv@exept.de>
parents:
3914
diff
changeset
|
447 |
"Modified: / 18.3.1999 / 18:30:11 / stefan" |
695 | 448 |
! |
77 | 449 |
|
2040
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
450 |
variableSubclass:nameSymbol instanceVariableNames:instVarNameString classVariableNames:classVarString poolDictionaries:pool category:cat |
20215 | 451 |
"create a new class which has nil as superclass |
2040
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
452 |
- i.e. traps into #doesNotUnderstand: for all of its messages." |
77 | 453 |
|
20215 | 454 |
^ self |
2040
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
455 |
nilSubclass:[ |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
456 |
Object class |
20215 | 457 |
name:nameSymbol |
4060
1048a3abf128
Use #query instead of #raise when invoking QuerySignals
Stefan Vogel <sv@exept.de>
parents:
3914
diff
changeset
|
458 |
inEnvironment:(Class nameSpaceQuerySignal query) |
2040
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
459 |
subclassOf:self |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
460 |
instanceVariableNames:instVarNameString |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
461 |
variable:true |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
462 |
words:false |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
463 |
pointers:true |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
464 |
classVariableNames:classVarString |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
465 |
poolDictionaries:pool |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
466 |
category:cat |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
467 |
comment:nil |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
468 |
changed:true |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
469 |
] |
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
470 |
|
4060
1048a3abf128
Use #query instead of #raise when invoking QuerySignals
Stefan Vogel <sv@exept.de>
parents:
3914
diff
changeset
|
471 |
"Modified: / 3.1.1997 / 16:00:45 / cg" |
1048a3abf128
Use #query instead of #raise when invoking QuerySignals
Stefan Vogel <sv@exept.de>
parents:
3914
diff
changeset
|
472 |
"Modified: / 18.3.1999 / 18:30:16 / stefan" |
695 | 473 |
! ! |
474 |
||
7262 | 475 |
!UndefinedObject methodsFor:'subclass creation-private'! |
5745 | 476 |
|
18480 | 477 |
subclass:nameSymbol instanceVariableNames:instVarNameString classVariableNames:classVarString poolDictionaries:pool privateIn:ownerClassArg |
20215 | 478 |
"create a new private class which has nil as superclass |
5745 | 479 |
- i.e. traps into #doesNotUnderstand: for all of its messages." |
480 |
||
18480 | 481 |
|category ownerClass| |
482 |
||
483 |
(ownerClass := ownerClassArg) isNil ifTrue:[ |
|
484 |
self error:'Nil (undefined) owner class - proceed to define as global' mayProceed:true. |
|
485 |
] ifFalse:[ |
|
486 |
category := ownerClassArg category |
|
487 |
]. |
|
20215 | 488 |
|
489 |
^ self |
|
5745 | 490 |
nilSubclass:[ |
491 |
Object class |
|
20215 | 492 |
name:nameSymbol |
5745 | 493 |
inEnvironment:ownerClass |
494 |
subclassOf:self |
|
495 |
instanceVariableNames:instVarNameString |
|
496 |
variable:false |
|
497 |
words:true |
|
498 |
pointers:true |
|
499 |
classVariableNames:classVarString |
|
500 |
poolDictionaries:pool |
|
18480 | 501 |
category:category |
5745 | 502 |
comment:nil |
503 |
changed:true |
|
504 |
] |
|
505 |
||
506 |
"Modified: / 3.1.1997 / 16:00:39 / cg" |
|
507 |
"Modified: / 18.3.1999 / 18:30:07 / stefan" |
|
508 |
! ! |
|
509 |
||
695 | 510 |
!UndefinedObject methodsFor:'testing'! |
511 |
||
1868 | 512 |
? defaultValue |
20191 | 513 |
"a syntactic sugar-piece: |
3466 | 514 |
if the receiver is nil, return the defaultValue; |
1868 | 515 |
otherwise, return the receiver. |
516 |
This method is redefined from Object; |
|
20215 | 517 |
the argument is returned unconditionally here. |
1868 | 518 |
|
1958 | 519 |
Thus, if foo and bar are simple variables or constants, |
520 |
foo ? bar |
|
521 |
is the same as: |
|
522 |
(foo isNil ifTrue:[bar] ifFalse:[foo]) |
|
523 |
||
524 |
if they are message sends, the equivalent code is: |
|
525 |
[ |
|
526 |
|t1 t2| |
|
527 |
||
528 |
t1 := foo. |
|
529 |
t2 := bar. |
|
530 |
t1 isNil ifTrue:[t2] ifFalse:[t1] |
|
531 |
] value |
|
532 |
||
1868 | 533 |
Can be used to provide defaultValues to variables, |
534 |
as in: |
|
1958 | 535 |
foo := arg ? #defaultValue |
1868 | 536 |
" |
537 |
||
538 |
^ defaultValue |
|
539 |
||
540 |
" |
|
541 |
1 ? #default |
|
20191 | 542 |
nil ? #default |
1868 | 543 |
" |
544 |
||
3466 | 545 |
"Created: / 4.11.1996 / 20:37:09 / cg" |
546 |
"Modified: / 19.5.1998 / 17:39:36 / cg" |
|
1868 | 547 |
! |
548 |
||
16127 | 549 |
?+ aOneArgBlock |
550 |
"a syntactic sugar-piece: |
|
551 |
aOneArgBlock is executed with self as argument |
|
552 |
if self is not nil. |
|
553 |
||
554 |
Note: this method should never be redefined in classes other than UndefinedObject. |
|
555 |
" |
|
556 |
||
557 |
^ self |
|
558 |
! |
|
559 |
||
3464
b0009b3ea4f2
added ?? - much like ?, but sends #value to its argument.
Claus Gittinger <cg@exept.de>
parents:
3183
diff
changeset
|
560 |
?? defaultValue |
11635 | 561 |
"a syntactic sugar-piece: |
3466 | 562 |
much like ?, but sends value to the argument if required. |
3464
b0009b3ea4f2
added ?? - much like ?, but sends #value to its argument.
Claus Gittinger <cg@exept.de>
parents:
3183
diff
changeset
|
563 |
If the receiver is nil, return the defaultValues value; |
b0009b3ea4f2
added ?? - much like ?, but sends #value to its argument.
Claus Gittinger <cg@exept.de>
parents:
3183
diff
changeset
|
564 |
otherwise, return the receiver. |
b0009b3ea4f2
added ?? - much like ?, but sends #value to its argument.
Claus Gittinger <cg@exept.de>
parents:
3183
diff
changeset
|
565 |
This method is redefined from Object. |
b0009b3ea4f2
added ?? - much like ?, but sends #value to its argument.
Claus Gittinger <cg@exept.de>
parents:
3183
diff
changeset
|
566 |
|
b0009b3ea4f2
added ?? - much like ?, but sends #value to its argument.
Claus Gittinger <cg@exept.de>
parents:
3183
diff
changeset
|
567 |
Thus, if foo and bar are simple variables or constants, |
b0009b3ea4f2
added ?? - much like ?, but sends #value to its argument.
Claus Gittinger <cg@exept.de>
parents:
3183
diff
changeset
|
568 |
foo ?? bar |
b0009b3ea4f2
added ?? - much like ?, but sends #value to its argument.
Claus Gittinger <cg@exept.de>
parents:
3183
diff
changeset
|
569 |
is the same as: |
b0009b3ea4f2
added ?? - much like ?, but sends #value to its argument.
Claus Gittinger <cg@exept.de>
parents:
3183
diff
changeset
|
570 |
(foo isNil ifTrue:[bar value] ifFalse:[foo]) |
b0009b3ea4f2
added ?? - much like ?, but sends #value to its argument.
Claus Gittinger <cg@exept.de>
parents:
3183
diff
changeset
|
571 |
|
b0009b3ea4f2
added ?? - much like ?, but sends #value to its argument.
Claus Gittinger <cg@exept.de>
parents:
3183
diff
changeset
|
572 |
if they are message sends, the equivalent code is: |
b0009b3ea4f2
added ?? - much like ?, but sends #value to its argument.
Claus Gittinger <cg@exept.de>
parents:
3183
diff
changeset
|
573 |
[ |
3466 | 574 |
|t| |
3464
b0009b3ea4f2
added ?? - much like ?, but sends #value to its argument.
Claus Gittinger <cg@exept.de>
parents:
3183
diff
changeset
|
575 |
|
3466 | 576 |
t := foo. |
577 |
t isNil ifTrue:[bar value] ifFalse:[t] |
|
3464
b0009b3ea4f2
added ?? - much like ?, but sends #value to its argument.
Claus Gittinger <cg@exept.de>
parents:
3183
diff
changeset
|
578 |
] value |
b0009b3ea4f2
added ?? - much like ?, but sends #value to its argument.
Claus Gittinger <cg@exept.de>
parents:
3183
diff
changeset
|
579 |
|
b0009b3ea4f2
added ?? - much like ?, but sends #value to its argument.
Claus Gittinger <cg@exept.de>
parents:
3183
diff
changeset
|
580 |
Can be used to provide defaultValues to variables, |
b0009b3ea4f2
added ?? - much like ?, but sends #value to its argument.
Claus Gittinger <cg@exept.de>
parents:
3183
diff
changeset
|
581 |
as in: |
b0009b3ea4f2
added ?? - much like ?, but sends #value to its argument.
Claus Gittinger <cg@exept.de>
parents:
3183
diff
changeset
|
582 |
foo := arg ?? [something] |
b0009b3ea4f2
added ?? - much like ?, but sends #value to its argument.
Claus Gittinger <cg@exept.de>
parents:
3183
diff
changeset
|
583 |
" |
b0009b3ea4f2
added ?? - much like ?, but sends #value to its argument.
Claus Gittinger <cg@exept.de>
parents:
3183
diff
changeset
|
584 |
|
b0009b3ea4f2
added ?? - much like ?, but sends #value to its argument.
Claus Gittinger <cg@exept.de>
parents:
3183
diff
changeset
|
585 |
^ defaultValue value |
b0009b3ea4f2
added ?? - much like ?, but sends #value to its argument.
Claus Gittinger <cg@exept.de>
parents:
3183
diff
changeset
|
586 |
|
b0009b3ea4f2
added ?? - much like ?, but sends #value to its argument.
Claus Gittinger <cg@exept.de>
parents:
3183
diff
changeset
|
587 |
" |
b0009b3ea4f2
added ?? - much like ?, but sends #value to its argument.
Claus Gittinger <cg@exept.de>
parents:
3183
diff
changeset
|
588 |
1 ?? #default |
20215 | 589 |
nil ?? #default |
590 |
1 ?? [Date today] |
|
591 |
nil ?? [Date today] |
|
3464
b0009b3ea4f2
added ?? - much like ?, but sends #value to its argument.
Claus Gittinger <cg@exept.de>
parents:
3183
diff
changeset
|
592 |
" |
b0009b3ea4f2
added ?? - much like ?, but sends #value to its argument.
Claus Gittinger <cg@exept.de>
parents:
3183
diff
changeset
|
593 |
|
b0009b3ea4f2
added ?? - much like ?, but sends #value to its argument.
Claus Gittinger <cg@exept.de>
parents:
3183
diff
changeset
|
594 |
"Created: / 4.11.1996 / 20:37:09 / cg" |
3466 | 595 |
"Modified: / 19.5.1998 / 17:42:10 / cg" |
3464
b0009b3ea4f2
added ?? - much like ?, but sends #value to its argument.
Claus Gittinger <cg@exept.de>
parents:
3183
diff
changeset
|
596 |
! |
b0009b3ea4f2
added ?? - much like ?, but sends #value to its argument.
Claus Gittinger <cg@exept.de>
parents:
3183
diff
changeset
|
597 |
|
7108
90b7cfc06ab8
More openErrorSignal change preparations
Stefan Vogel <sv@exept.de>
parents:
6932
diff
changeset
|
598 |
checkNilFileStream |
90b7cfc06ab8
More openErrorSignal change preparations
Stefan Vogel <sv@exept.de>
parents:
6932
diff
changeset
|
599 |
"Do nothing if this is a valid FileStream |
90b7cfc06ab8
More openErrorSignal change preparations
Stefan Vogel <sv@exept.de>
parents:
6932
diff
changeset
|
600 |
(i.e. the previous open operation was successful). |
90b7cfc06ab8
More openErrorSignal change preparations
Stefan Vogel <sv@exept.de>
parents:
6932
diff
changeset
|
601 |
Also implemented in UndefinedObject, to raise an Error there. |
90b7cfc06ab8
More openErrorSignal change preparations
Stefan Vogel <sv@exept.de>
parents:
6932
diff
changeset
|
602 |
|
90b7cfc06ab8
More openErrorSignal change preparations
Stefan Vogel <sv@exept.de>
parents:
6932
diff
changeset
|
603 |
This is an aid for converting from the old error reporting (returning nil) |
11635 | 604 |
to the new error reporting (with real Exceptions). |
7108
90b7cfc06ab8
More openErrorSignal change preparations
Stefan Vogel <sv@exept.de>
parents:
6932
diff
changeset
|
605 |
|
90b7cfc06ab8
More openErrorSignal change preparations
Stefan Vogel <sv@exept.de>
parents:
6932
diff
changeset
|
606 |
It will vanish as soon as the conversion has been done" |
90b7cfc06ab8
More openErrorSignal change preparations
Stefan Vogel <sv@exept.de>
parents:
6932
diff
changeset
|
607 |
|
16127 | 608 |
^ OpenError raise |
7108
90b7cfc06ab8
More openErrorSignal change preparations
Stefan Vogel <sv@exept.de>
parents:
6932
diff
changeset
|
609 |
! |
90b7cfc06ab8
More openErrorSignal change preparations
Stefan Vogel <sv@exept.de>
parents:
6932
diff
changeset
|
610 |
|
695 | 611 |
hash |
612 |
"return an integer useful as a hash key" |
|
613 |
||
614 |
^ 0 |
|
615 |
! |
|
616 |
||
617 |
identityHash |
|
618 |
"return an integer useful as a hash key" |
|
619 |
||
620 |
^ 0 |
|
621 |
! |
|
622 |
||
4339
18c19912a67c
added #ifNil and friends - squeak compatibility.
Claus Gittinger <cg@exept.de>
parents:
4321
diff
changeset
|
623 |
ifNil:aBlockOrValue |
18c19912a67c
added #ifNil and friends - squeak compatibility.
Claus Gittinger <cg@exept.de>
parents:
4321
diff
changeset
|
624 |
"return myself, or the result from evaluating the argument, if I am nil. |
18c19912a67c
added #ifNil and friends - squeak compatibility.
Claus Gittinger <cg@exept.de>
parents:
4321
diff
changeset
|
625 |
This is much like #?, but sends #value to the argument in case of a nil |
5796 | 626 |
receiver. |
627 |
Notice: |
|
628 |
This method is open coded (inlined) by the compiler(s) |
|
629 |
- redefining it may not work as expected." |
|
4339
18c19912a67c
added #ifNil and friends - squeak compatibility.
Claus Gittinger <cg@exept.de>
parents:
4321
diff
changeset
|
630 |
|
18c19912a67c
added #ifNil and friends - squeak compatibility.
Claus Gittinger <cg@exept.de>
parents:
4321
diff
changeset
|
631 |
^ aBlockOrValue value |
18c19912a67c
added #ifNil and friends - squeak compatibility.
Claus Gittinger <cg@exept.de>
parents:
4321
diff
changeset
|
632 |
! |
18c19912a67c
added #ifNil and friends - squeak compatibility.
Claus Gittinger <cg@exept.de>
parents:
4321
diff
changeset
|
633 |
|
18c19912a67c
added #ifNil and friends - squeak compatibility.
Claus Gittinger <cg@exept.de>
parents:
4321
diff
changeset
|
634 |
ifNil:nilBlockOrValue ifNotNil:notNilBlockOrValue |
18c19912a67c
added #ifNil and friends - squeak compatibility.
Claus Gittinger <cg@exept.de>
parents:
4321
diff
changeset
|
635 |
"return the value of the first arg, if I am nil, |
5796 | 636 |
the result from evaluating the 2nd argument, if I am not nil. |
637 |
Notice: |
|
638 |
This method is open coded (inlined) by the compiler(s) |
|
639 |
- redefining it may not work as expected." |
|
4339
18c19912a67c
added #ifNil and friends - squeak compatibility.
Claus Gittinger <cg@exept.de>
parents:
4321
diff
changeset
|
640 |
|
18c19912a67c
added #ifNil and friends - squeak compatibility.
Claus Gittinger <cg@exept.de>
parents:
4321
diff
changeset
|
641 |
^ nilBlockOrValue value |
18c19912a67c
added #ifNil and friends - squeak compatibility.
Claus Gittinger <cg@exept.de>
parents:
4321
diff
changeset
|
642 |
! |
18c19912a67c
added #ifNil and friends - squeak compatibility.
Claus Gittinger <cg@exept.de>
parents:
4321
diff
changeset
|
643 |
|
18c19912a67c
added #ifNil and friends - squeak compatibility.
Claus Gittinger <cg@exept.de>
parents:
4321
diff
changeset
|
644 |
ifNotNil:aBlockOrValue |
5796 | 645 |
"return myself if nil, or the result from evaluating the argument, if I am not nil. |
646 |
Notice: |
|
647 |
This method is open coded (inlined) by the compiler(s) |
|
648 |
- redefining it may not work as expected." |
|
4339
18c19912a67c
added #ifNil and friends - squeak compatibility.
Claus Gittinger <cg@exept.de>
parents:
4321
diff
changeset
|
649 |
|
8574 | 650 |
^ nil |
4339
18c19912a67c
added #ifNil and friends - squeak compatibility.
Claus Gittinger <cg@exept.de>
parents:
4321
diff
changeset
|
651 |
! |
18c19912a67c
added #ifNil and friends - squeak compatibility.
Claus Gittinger <cg@exept.de>
parents:
4321
diff
changeset
|
652 |
|
18c19912a67c
added #ifNil and friends - squeak compatibility.
Claus Gittinger <cg@exept.de>
parents:
4321
diff
changeset
|
653 |
ifNotNil:notNilBlockOrValue ifNil:nilBlockOrValue |
18c19912a67c
added #ifNil and friends - squeak compatibility.
Claus Gittinger <cg@exept.de>
parents:
4321
diff
changeset
|
654 |
"return the value of the 2nd arg, if I am nil, |
5796 | 655 |
the result from evaluating the 1st argument, if I am not nil. |
656 |
Notice: |
|
657 |
This method is open coded (inlined) by the compiler(s) |
|
658 |
- redefining it may not work as expected." |
|
4339
18c19912a67c
added #ifNil and friends - squeak compatibility.
Claus Gittinger <cg@exept.de>
parents:
4321
diff
changeset
|
659 |
|
18c19912a67c
added #ifNil and friends - squeak compatibility.
Claus Gittinger <cg@exept.de>
parents:
4321
diff
changeset
|
660 |
^ nilBlockOrValue value |
18c19912a67c
added #ifNil and friends - squeak compatibility.
Claus Gittinger <cg@exept.de>
parents:
4321
diff
changeset
|
661 |
! |
18c19912a67c
added #ifNil and friends - squeak compatibility.
Claus Gittinger <cg@exept.de>
parents:
4321
diff
changeset
|
662 |
|
8574 | 663 |
ifNotNilDo:aBlock |
20352 | 664 |
"if the receiver is non-nil, return the value of aBlock, passing myself as argument. |
8574 | 665 |
Otherwise do nothing and return nil." |
666 |
||
667 |
^ nil |
|
668 |
! |
|
669 |
||
6181 | 670 |
isEmptyOrNil |
20215 | 671 |
"return true if I am nil or an empty collection |
21809 | 672 |
- since I am nil, return true. (from Squeak)" |
6181 | 673 |
|
674 |
^ true |
|
675 |
||
13588 | 676 |
"Created: / 13-11-2001 / 13:16:40 / cg" |
677 |
"Modified (comment): / 17-08-2011 / 09:29:30 / cg" |
|
21809 | 678 |
"Modified (comment): / 15-06-2017 / 01:46:00 / mawalch" |
6181 | 679 |
! |
680 |
||
695 | 681 |
isLiteral |
20215 | 682 |
"return true if the receiver can be used as a literal constant in ST syntax |
695 | 683 |
(i.e. can be used in constant arrays)" |
77 | 684 |
|
695 | 685 |
^ true |
686 |
! |
|
687 |
||
688 |
isNil |
|
20215 | 689 |
"Return true if the receiver is nil. |
9223 | 690 |
Since I am definitely nil, unconditionally return true here. |
3044 | 691 |
Notice: |
9223 | 692 |
This method is open coded (inlined) by the compiler(s) |
693 |
- redefining it may not work as expected." |
|
695 | 694 |
|
695 |
^ true |
|
696 |
! |
|
697 |
||
6068
1d5ca1175f3f
added #isNilOrEmptyCollection
Claus Gittinger <cg@exept.de>
parents:
5796
diff
changeset
|
698 |
isNilOrEmptyCollection |
8833 | 699 |
"return true if I am nil or an empty collection - false here. |
700 |
Obsolete, use isEmptyOrNil." |
|
701 |
||
702 |
<resource:#obsolete> |
|
6068
1d5ca1175f3f
added #isNilOrEmptyCollection
Claus Gittinger <cg@exept.de>
parents:
5796
diff
changeset
|
703 |
|
1d5ca1175f3f
added #isNilOrEmptyCollection
Claus Gittinger <cg@exept.de>
parents:
5796
diff
changeset
|
704 |
^ true |
6182 | 705 |
|
706 |
"Modified: / 13.11.2001 / 13:28:15 / cg" |
|
6068
1d5ca1175f3f
added #isNilOrEmptyCollection
Claus Gittinger <cg@exept.de>
parents:
5796
diff
changeset
|
707 |
! |
1d5ca1175f3f
added #isNilOrEmptyCollection
Claus Gittinger <cg@exept.de>
parents:
5796
diff
changeset
|
708 |
|
16908
25523cfdfa62
added: Object>>isNotNil
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16721
diff
changeset
|
709 |
isNotNil |
20215 | 710 |
<resource: #obsolete> |
711 |
||
712 |
"Return true if the receiver is not nil. |
|
713 |
Since I am definitely nil, unconditionally return false here. |
|
16908
25523cfdfa62
added: Object>>isNotNil
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16721
diff
changeset
|
714 |
the receiver is definitely not nil here, so unconditionally return false." |
25523cfdfa62
added: Object>>isNotNil
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16721
diff
changeset
|
715 |
|
20215 | 716 |
self obsoleteMethodWarning:'use #notNil'. |
16908
25523cfdfa62
added: Object>>isNotNil
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16721
diff
changeset
|
717 |
^ false |
25523cfdfa62
added: Object>>isNotNil
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16721
diff
changeset
|
718 |
|
25523cfdfa62
added: Object>>isNotNil
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16721
diff
changeset
|
719 |
"Created: / 26-10-2014 / 01:30:15 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
25523cfdfa62
added: Object>>isNotNil
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16721
diff
changeset
|
720 |
! |
25523cfdfa62
added: Object>>isNotNil
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16721
diff
changeset
|
721 |
|
6932 | 722 |
notEmptyOrNil |
723 |
"Squeak compatibility: |
|
724 |
return true if I am neither nil nor an empty collection." |
|
725 |
||
726 |
^ false |
|
727 |
! |
|
728 |
||
695 | 729 |
notNil |
20215 | 730 |
"Return true if the receiver is not nil. |
9223 | 731 |
Since I am definitely nil, unconditionally return false here. |
3044 | 732 |
Notice: |
9223 | 733 |
This method is open coded (inlined) by the compiler(s) |
734 |
- redefining it may not work as expected." |
|
77 | 735 |
|
695 | 736 |
^ false |
77 | 737 |
! ! |
695 | 738 |
|
4652
8b3118a923d1
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
739 |
!UndefinedObject methodsFor:'tracing'! |
8b3118a923d1
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
740 |
|
4682 | 741 |
traceInto:aRequestor level:level from:referrer |
4652
8b3118a923d1
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
742 |
"double dispatch into tracer, passing my type implicitely in the selector" |
8b3118a923d1
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
743 |
|
4682 | 744 |
^ aRequestor traceUndefinedObject:self level:level from:referrer |
4652
8b3118a923d1
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
745 |
|
8b3118a923d1
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
746 |
|
8b3118a923d1
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
747 |
! ! |
8b3118a923d1
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4530
diff
changeset
|
748 |
|
8395
6bd97113cb4c
Generalize visitor pattern and define #visit...:with: -methods instead
Stefan Vogel <sv@exept.de>
parents:
8383
diff
changeset
|
749 |
!UndefinedObject methodsFor:'visiting'! |
6bd97113cb4c
Generalize visitor pattern and define #visit...:with: -methods instead
Stefan Vogel <sv@exept.de>
parents:
8383
diff
changeset
|
750 |
|
6bd97113cb4c
Generalize visitor pattern and define #visit...:with: -methods instead
Stefan Vogel <sv@exept.de>
parents:
8383
diff
changeset
|
751 |
acceptVisitor:aVisitor with:aParameter |
16721 | 752 |
"dispatch for visitor pattern; send #visitNil:with: to aVisitor." |
8395
6bd97113cb4c
Generalize visitor pattern and define #visit...:with: -methods instead
Stefan Vogel <sv@exept.de>
parents:
8383
diff
changeset
|
753 |
|
6bd97113cb4c
Generalize visitor pattern and define #visit...:with: -methods instead
Stefan Vogel <sv@exept.de>
parents:
8383
diff
changeset
|
754 |
^ aVisitor visitNilWith:aParameter |
6bd97113cb4c
Generalize visitor pattern and define #visit...:with: -methods instead
Stefan Vogel <sv@exept.de>
parents:
8383
diff
changeset
|
755 |
! ! |
6bd97113cb4c
Generalize visitor pattern and define #visit...:with: -methods instead
Stefan Vogel <sv@exept.de>
parents:
8383
diff
changeset
|
756 |
|
695 | 757 |
!UndefinedObject class methodsFor:'documentation'! |
758 |
||
759 |
version |
|
18480 | 760 |
^ '$Header$' |
12968
07761a8bcc6a
comment/format in: #addDependent:
Claus Gittinger <cg@exept.de>
parents:
11821
diff
changeset
|
761 |
! |
07761a8bcc6a
comment/format in: #addDependent:
Claus Gittinger <cg@exept.de>
parents:
11821
diff
changeset
|
762 |
|
07761a8bcc6a
comment/format in: #addDependent:
Claus Gittinger <cg@exept.de>
parents:
11821
diff
changeset
|
763 |
version_CVS |
18480 | 764 |
^ '$Header$' |
695 | 765 |
! ! |
6932 | 766 |
|
14678 | 767 |
|
2040
8ba8b1002902
avoid intermediate Object subclass creation.
Claus Gittinger <cg@exept.de>
parents:
1958
diff
changeset
|
768 |
UndefinedObject initialize! |