22581
|
1 |
"{ Encoding: utf8 }"
|
|
2 |
|
1
|
3 |
"
|
5
|
4 |
COPYRIGHT (c) 1988 by Claus Gittinger
|
379
|
5 |
All Rights Reserved
|
1
|
6 |
|
|
7 |
This software is furnished under a license and may be used
|
|
8 |
only in accordance with the terms of that license and with the
|
|
9 |
inclusion of the above copyright notice. This software may not
|
|
10 |
be provided or otherwise made available to, or used by, any
|
|
11 |
other person. No title to or ownership of the software is
|
|
12 |
hereby transferred.
|
|
13 |
"
|
6906
|
14 |
"{ Package: 'stx:libbasic' }"
|
|
15 |
|
19112
|
16 |
"{ NameSpace: Smalltalk }"
|
|
17 |
|
1
|
18 |
Boolean subclass:#False
|
1238
|
19 |
instanceVariableNames:''
|
|
20 |
classVariableNames:''
|
|
21 |
poolDictionaries:''
|
|
22 |
category:'Kernel-Objects'
|
1
|
23 |
!
|
|
24 |
|
88
|
25 |
!False class methodsFor:'documentation'!
|
|
26 |
|
|
27 |
copyright
|
|
28 |
"
|
|
29 |
COPYRIGHT (c) 1988 by Claus Gittinger
|
379
|
30 |
All Rights Reserved
|
1
|
31 |
|
88
|
32 |
This software is furnished under a license and may be used
|
|
33 |
only in accordance with the terms of that license and with the
|
|
34 |
inclusion of the above copyright notice. This software may not
|
|
35 |
be provided or otherwise made available to, or used by, any
|
|
36 |
other person. No title to or ownership of the software is
|
|
37 |
hereby transferred.
|
|
38 |
"
|
|
39 |
!
|
1
|
40 |
|
88
|
41 |
documentation
|
|
42 |
"
|
|
43 |
False has only one instance, false, representing logical falsehood.
|
1238
|
44 |
|
88
|
45 |
Some methods are implemented here and in True, instead of the common
|
20195
|
46 |
superclass Boolean. This has the advantage that no truth-value checks
|
|
47 |
are needed, but instead the truth check is done in the method lookup.
|
88
|
48 |
However, remember that some messages to booleans are inline coded in
|
|
49 |
the compilers (both interpreted and machine code). Therefore redefinition
|
|
50 |
of some methods here will not have any effect on compiled code.
|
|
51 |
(redefining ifTrue: to something else will probably crash the smalltalk
|
|
52 |
world anyway ...)
|
1294
|
53 |
|
1303
|
54 |
[see also:]
|
|
55 |
True
|
|
56 |
|
1294
|
57 |
[author:]
|
|
58 |
Claus Gittinger
|
574
|
59 |
"
|
692
|
60 |
! !
|
1
|
61 |
|
11759
|
62 |
|
19112
|
63 |
|
1
|
64 |
!False methodsFor:'conditional evaluation'!
|
|
65 |
|
|
66 |
and:aBlock
|
|
67 |
"evaluate aBlock if the receiver is true.
|
11917
|
68 |
(since the receiver is known to be false here, always return false here).
|
3044
|
69 |
Notice:
|
11917
|
70 |
This method is open coded (inlined) by the compiler(s)
|
|
71 |
- redefining it may not work as expected."
|
1
|
72 |
|
|
73 |
^ self
|
|
74 |
!
|
|
75 |
|
11818
|
76 |
and:block1 and:block2
|
11917
|
77 |
"evaluate block1 if the receiver is true; if that also returns true, evaluate block2.
|
|
78 |
(since the receiver is known to be false here, always return false here).
|
|
79 |
Notice:
|
|
80 |
This method is open coded (inlined) by the compiler(s)
|
|
81 |
- redefining it may not work as expected."
|
11825
|
82 |
|
|
83 |
^ self
|
|
84 |
!
|
|
85 |
|
|
86 |
and:block1 and:block2 and:block3
|
22674
|
87 |
"evaluate block1 if the receiver is true;
|
|
88 |
if that also returns true, evaluate block2;
|
|
89 |
if that also returns true, evaluate block3.
|
|
90 |
(since the receiver is known to be false here, always return false here).
|
|
91 |
Notice:
|
|
92 |
This method may be open coded (inlined) by the compiler(s)
|
|
93 |
- redefining it may not work as expected."
|
11825
|
94 |
|
|
95 |
^ self
|
|
96 |
!
|
|
97 |
|
|
98 |
and:block1 and:block2 and:block3 and:block4
|
22674
|
99 |
"evaluate block1 if the receiver is true;
|
|
100 |
if that also returns true, evaluate block2;
|
|
101 |
if that also returns true, evaluate block3.
|
|
102 |
if that also returns true, evaluate block4.
|
|
103 |
(since the receiver is known to be false here, always return false here).
|
|
104 |
Notice:
|
|
105 |
This method may be open coded (inlined) by the compiler(s)
|
|
106 |
- redefining it may not work as expected."
|
11825
|
107 |
|
11818
|
108 |
^ self
|
|
109 |
!
|
|
110 |
|
1
|
111 |
ifFalse:aBlock
|
9225
|
112 |
"If the receiver is false, return the value of evaluating aBlock; nil otherwise.
|
23890
|
113 |
Since the receiver is definitely false here, unconditionally return the block's value.
|
3044
|
114 |
Notice:
|
9225
|
115 |
This method is open coded (inlined) by the compiler(s)
|
|
116 |
- redefining it may not work as expected."
|
1
|
117 |
|
|
118 |
^ aBlock value
|
23890
|
119 |
|
|
120 |
"Modified (comment): / 13-03-2019 / 10:23:10 / Claus Gittinger"
|
1
|
121 |
!
|
|
122 |
|
574
|
123 |
ifFalse:falseBlock ifTrue:trueBlock
|
|
124 |
"return the value of evaluating falseBlock (since the receiver is false)
|
3044
|
125 |
Notice:
|
|
126 |
This method is open coded (inlined) by the compiler(s)
|
|
127 |
- redefining it may not work as expected."
|
574
|
128 |
|
|
129 |
^ falseBlock value
|
|
130 |
!
|
|
131 |
|
1
|
132 |
ifTrue:aBlock
|
9225
|
133 |
"If the receiver is true, return the value of evaluating aBlock; nil otherwise.
|
|
134 |
Since the receiver is definitely false here, unconditionally return nil value.
|
3044
|
135 |
Notice:
|
9225
|
136 |
This method is open coded (inlined) by the compiler(s)
|
|
137 |
- redefining it may not work as expected."
|
1
|
138 |
|
|
139 |
^ nil
|
|
140 |
!
|
|
141 |
|
|
142 |
ifTrue:trueBlock ifFalse:falseBlock
|
|
143 |
"return the value of evaluating falseBlock (since the receiver is false)
|
3044
|
144 |
Notice:
|
|
145 |
This method is open coded (inlined) by the compiler(s)
|
|
146 |
- redefining it may not work as expected."
|
1
|
147 |
|
|
148 |
^ falseBlock value
|
|
149 |
!
|
|
150 |
|
574
|
151 |
or:aBlock
|
|
152 |
"evaluate aBlock if the receiver is false.
|
|
153 |
(since the receiver is false return the value of evaluating aBlock).
|
3044
|
154 |
Notice:
|
|
155 |
This method is open coded (inlined) by the compiler(s)
|
|
156 |
- redefining it may not work as expected."
|
1
|
157 |
|
574
|
158 |
^ aBlock value
|
11825
|
159 |
!
|
|
160 |
|
|
161 |
or:block1 or:block2
|
22674
|
162 |
"evaluate block1 if the receiver is false.
|
|
163 |
if that evaluates to false, return the result from block2.
|
|
164 |
(since the receiver is false return the value of evaluating aBlock).
|
|
165 |
Notice:
|
|
166 |
This method may be open coded (inlined) by the compiler(s)
|
|
167 |
- redefining it may not work as expected."
|
|
168 |
|
11825
|
169 |
block1 value ifTrue:[^ true].
|
|
170 |
^ block2 value
|
|
171 |
!
|
|
172 |
|
|
173 |
or:block1 or:block2 or:block3
|
22674
|
174 |
"evaluate block1 if the receiver is false.
|
|
175 |
if that evaluates to false, return the result from block2.
|
|
176 |
if that evaluates to false, return the result from block3.
|
|
177 |
(since the receiver is false return the value of evaluating aBlock).
|
|
178 |
Notice:
|
|
179 |
This method may be open coded (inlined) by the compiler(s)
|
|
180 |
- redefining it may not work as expected."
|
|
181 |
|
11825
|
182 |
block1 value ifTrue:[^ true].
|
|
183 |
block2 value ifTrue:[^ true].
|
|
184 |
^ block3 value
|
|
185 |
!
|
|
186 |
|
|
187 |
or:block1 or:block2 or:block3 or:block4
|
22674
|
188 |
"evaluate block1 if the receiver is false.
|
|
189 |
if that evaluates to false, return the result from block2.
|
|
190 |
if that evaluates to false, return the result from block3.
|
|
191 |
if that evaluates to false, return the result from block4.
|
|
192 |
(since the receiver is false return the value of evaluating aBlock).
|
|
193 |
Notice:
|
|
194 |
This method may be open coded (inlined) by the compiler(s)
|
|
195 |
- redefining it may not work as expected."
|
|
196 |
|
11825
|
197 |
block1 value ifTrue:[^ true].
|
|
198 |
block2 value ifTrue:[^ true].
|
|
199 |
block3 value ifTrue:[^ true].
|
|
200 |
^ block4 value
|
1
|
201 |
! !
|
|
202 |
|
10817
|
203 |
!False methodsFor:'converting'!
|
|
204 |
|
11759
|
205 |
asInteger
|
|
206 |
"false->0; true->1"
|
|
207 |
|
|
208 |
^ 0
|
|
209 |
!
|
|
210 |
|
10817
|
211 |
asNumber
|
|
212 |
"false->0; true->1"
|
|
213 |
|
|
214 |
^ 0
|
|
215 |
! !
|
|
216 |
|
22051
|
217 |
!False methodsFor:'debugging'!
|
|
218 |
|
|
219 |
haltIfFalse
|
|
220 |
"halt if the receiver is true"
|
|
221 |
|
|
222 |
<resource: #skipInDebuggersWalkBack>
|
|
223 |
|
|
224 |
self halt
|
|
225 |
|
|
226 |
"
|
|
227 |
3 haltIfNil
|
|
228 |
nil haltIfNil
|
|
229 |
|
|
230 |
true haltIfTrue
|
|
231 |
true haltIfFalse
|
|
232 |
|
|
233 |
false haltIfTrue
|
|
234 |
false haltIfFalse
|
|
235 |
"
|
|
236 |
|
|
237 |
"Created: / 17-07-2017 / 17:44:26 / cg"
|
|
238 |
!
|
|
239 |
|
|
240 |
haltIfTrue
|
|
241 |
"halt if the receiver is true"
|
|
242 |
|
|
243 |
<resource: #skipInDebuggersWalkBack>
|
|
244 |
|
|
245 |
^ self
|
|
246 |
|
|
247 |
"
|
|
248 |
3 haltIfNil
|
|
249 |
nil haltIfNil
|
|
250 |
"
|
|
251 |
|
|
252 |
"Created: / 17-07-2017 / 17:43:01 / cg"
|
|
253 |
! !
|
|
254 |
|
23890
|
255 |
|
574
|
256 |
!False methodsFor:'logical operations'!
|
|
257 |
|
|
258 |
& aBoolean
|
|
259 |
"return true, if both the receiver and the argument are true
|
6906
|
260 |
(since the receiver is false, return false)
|
|
261 |
Notice:
|
|
262 |
as this is a binary message, the argument is always evaluated.
|
|
263 |
It might be better to use and:[...], which does not evaluate
|
|
264 |
the argument if the receiver is already false."
|
574
|
265 |
|
|
266 |
^ false
|
|
267 |
!
|
|
268 |
|
22581
|
269 |
==> aBoolean
|
|
270 |
"same as implies:
|
|
271 |
return true if receiver => argument"
|
|
272 |
|
|
273 |
^ true
|
|
274 |
!
|
|
275 |
|
574
|
276 |
eqv:aBoolean
|
|
277 |
"return true, if the receiver and the argument are the same truth value
|
|
278 |
(since the receiver is false, return true if the argument is also false)"
|
|
279 |
|
|
280 |
^ aBoolean not
|
|
281 |
!
|
|
282 |
|
9000
|
283 |
implies:aBoolean
|
|
284 |
"return true if receiver => argument"
|
|
285 |
|
|
286 |
^ true
|
|
287 |
!
|
|
288 |
|
574
|
289 |
not
|
|
290 |
"return true, if the receiver is false, false otherwise
|
3044
|
291 |
(since the receiver is false, return true).
|
|
292 |
Notice:
|
|
293 |
This method is open coded (inlined) by the compiler(s)
|
|
294 |
- redefining it may not work as expected."
|
574
|
295 |
|
|
296 |
^ true
|
|
297 |
!
|
|
298 |
|
|
299 |
xor:aBoolean
|
|
300 |
"return true, if the receiver and the argument are different truth values
|
|
301 |
(since the receiver is false, return true, if the armument is not false)"
|
|
302 |
|
|
303 |
^ aBoolean
|
|
304 |
!
|
|
305 |
|
|
306 |
| aBoolean
|
|
307 |
"return true, if either the receiver or the argument is true
|
6906
|
308 |
(since the receiver is false, return the argument).
|
|
309 |
Notice:
|
|
310 |
as this is a binary message, the argument is always evaluated.
|
|
311 |
It might be better to use or:[...], which does not evaluate
|
|
312 |
the argument if the receiver is already true."
|
574
|
313 |
|
|
314 |
^ aBoolean
|
|
315 |
! !
|
|
316 |
|
|
317 |
!False methodsFor:'printing & storing'!
|
1
|
318 |
|
|
319 |
printString
|
54
|
320 |
"return character sequence representing the receiver"
|
1
|
321 |
|
|
322 |
^ 'false'
|
|
323 |
! !
|
2
|
324 |
|
692
|
325 |
!False class methodsFor:'documentation'!
|
|
326 |
|
|
327 |
version
|
19112
|
328 |
^ '$Header$'
|
6906
|
329 |
! !
|
19112
|
330 |
|