1
|
1 |
"
|
5
|
2 |
COPYRIGHT (c) 1988 by Claus Gittinger
|
379
|
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 |
"
|
6906
|
12 |
"{ Package: 'stx:libbasic' }"
|
|
13 |
|
19112
|
14 |
"{ NameSpace: Smalltalk }"
|
|
15 |
|
1
|
16 |
Boolean subclass:#False
|
1238
|
17 |
instanceVariableNames:''
|
|
18 |
classVariableNames:''
|
|
19 |
poolDictionaries:''
|
|
20 |
category:'Kernel-Objects'
|
1
|
21 |
!
|
|
22 |
|
88
|
23 |
!False class methodsFor:'documentation'!
|
|
24 |
|
|
25 |
copyright
|
|
26 |
"
|
|
27 |
COPYRIGHT (c) 1988 by Claus Gittinger
|
379
|
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 |
!
|
1
|
38 |
|
88
|
39 |
documentation
|
|
40 |
"
|
|
41 |
False has only one instance, false, representing logical falsehood.
|
1238
|
42 |
|
88
|
43 |
Some methods are implemented here and in True, instead of the common
|
20195
|
44 |
superclass Boolean. This has the advantage that no truth-value checks
|
|
45 |
are needed, but instead the truth check is done in the method lookup.
|
88
|
46 |
However, remember that some messages to booleans are inline coded in
|
|
47 |
the compilers (both interpreted and machine code). Therefore redefinition
|
|
48 |
of some methods here will not have any effect on compiled code.
|
|
49 |
(redefining ifTrue: to something else will probably crash the smalltalk
|
|
50 |
world anyway ...)
|
1294
|
51 |
|
1303
|
52 |
[see also:]
|
|
53 |
True
|
|
54 |
|
1294
|
55 |
[author:]
|
|
56 |
Claus Gittinger
|
574
|
57 |
"
|
692
|
58 |
! !
|
1
|
59 |
|
11759
|
60 |
|
19112
|
61 |
|
1
|
62 |
!False methodsFor:'conditional evaluation'!
|
|
63 |
|
|
64 |
and:aBlock
|
|
65 |
"evaluate aBlock if the receiver is true.
|
11917
|
66 |
(since the receiver is known to be false here, always return false here).
|
3044
|
67 |
Notice:
|
11917
|
68 |
This method is open coded (inlined) by the compiler(s)
|
|
69 |
- redefining it may not work as expected."
|
1
|
70 |
|
|
71 |
^ self
|
|
72 |
!
|
|
73 |
|
11818
|
74 |
and:block1 and:block2
|
11917
|
75 |
"evaluate block1 if the receiver is true; if that also returns true, evaluate block2.
|
|
76 |
(since the receiver is known to be false here, always return false here).
|
|
77 |
Notice:
|
|
78 |
This method is open coded (inlined) by the compiler(s)
|
|
79 |
- redefining it may not work as expected."
|
11825
|
80 |
|
|
81 |
^ self
|
|
82 |
!
|
|
83 |
|
|
84 |
and:block1 and:block2 and:block3
|
|
85 |
"return false"
|
|
86 |
|
|
87 |
^ self
|
|
88 |
!
|
|
89 |
|
|
90 |
and:block1 and:block2 and:block3 and:block4
|
|
91 |
"return false"
|
|
92 |
|
11818
|
93 |
^ self
|
|
94 |
!
|
|
95 |
|
1
|
96 |
ifFalse:aBlock
|
9225
|
97 |
"If the receiver is false, return the value of evaluating aBlock; nil otherwise.
|
|
98 |
Since the receiver is definitely false here, unconditionally return the blocks value.
|
3044
|
99 |
Notice:
|
9225
|
100 |
This method is open coded (inlined) by the compiler(s)
|
|
101 |
- redefining it may not work as expected."
|
1
|
102 |
|
|
103 |
^ aBlock value
|
|
104 |
!
|
|
105 |
|
574
|
106 |
ifFalse:falseBlock ifTrue:trueBlock
|
|
107 |
"return the value of evaluating falseBlock (since the receiver is false)
|
3044
|
108 |
Notice:
|
|
109 |
This method is open coded (inlined) by the compiler(s)
|
|
110 |
- redefining it may not work as expected."
|
574
|
111 |
|
|
112 |
^ falseBlock value
|
|
113 |
!
|
|
114 |
|
1
|
115 |
ifTrue:aBlock
|
9225
|
116 |
"If the receiver is true, return the value of evaluating aBlock; nil otherwise.
|
|
117 |
Since the receiver is definitely false here, unconditionally return nil value.
|
3044
|
118 |
Notice:
|
9225
|
119 |
This method is open coded (inlined) by the compiler(s)
|
|
120 |
- redefining it may not work as expected."
|
1
|
121 |
|
|
122 |
^ nil
|
|
123 |
!
|
|
124 |
|
|
125 |
ifTrue:trueBlock ifFalse:falseBlock
|
|
126 |
"return the value of evaluating falseBlock (since the receiver is false)
|
3044
|
127 |
Notice:
|
|
128 |
This method is open coded (inlined) by the compiler(s)
|
|
129 |
- redefining it may not work as expected."
|
1
|
130 |
|
|
131 |
^ falseBlock value
|
|
132 |
!
|
|
133 |
|
574
|
134 |
or:aBlock
|
|
135 |
"evaluate aBlock if the receiver is false.
|
|
136 |
(since the receiver is false return the value of evaluating aBlock).
|
3044
|
137 |
Notice:
|
|
138 |
This method is open coded (inlined) by the compiler(s)
|
|
139 |
- redefining it may not work as expected."
|
1
|
140 |
|
574
|
141 |
^ aBlock value
|
11825
|
142 |
!
|
|
143 |
|
|
144 |
or:block1 or:block2
|
|
145 |
block1 value ifTrue:[^ true].
|
|
146 |
^ block2 value
|
|
147 |
!
|
|
148 |
|
|
149 |
or:block1 or:block2 or:block3
|
|
150 |
block1 value ifTrue:[^ true].
|
|
151 |
block2 value ifTrue:[^ true].
|
|
152 |
^ block3 value
|
|
153 |
!
|
|
154 |
|
|
155 |
or:block1 or:block2 or:block3 or:block4
|
|
156 |
block1 value ifTrue:[^ true].
|
|
157 |
block2 value ifTrue:[^ true].
|
|
158 |
block3 value ifTrue:[^ true].
|
|
159 |
^ block4 value
|
1
|
160 |
! !
|
|
161 |
|
10817
|
162 |
!False methodsFor:'converting'!
|
|
163 |
|
11759
|
164 |
asInteger
|
|
165 |
"false->0; true->1"
|
|
166 |
|
|
167 |
^ 0
|
|
168 |
!
|
|
169 |
|
10817
|
170 |
asNumber
|
|
171 |
"false->0; true->1"
|
|
172 |
|
|
173 |
^ 0
|
|
174 |
! !
|
|
175 |
|
574
|
176 |
!False methodsFor:'logical operations'!
|
|
177 |
|
|
178 |
& aBoolean
|
|
179 |
"return true, if both the receiver and the argument are true
|
6906
|
180 |
(since the receiver is false, return false)
|
|
181 |
Notice:
|
|
182 |
as this is a binary message, the argument is always evaluated.
|
|
183 |
It might be better to use and:[...], which does not evaluate
|
|
184 |
the argument if the receiver is already false."
|
574
|
185 |
|
|
186 |
^ false
|
|
187 |
!
|
|
188 |
|
|
189 |
eqv:aBoolean
|
|
190 |
"return true, if the receiver and the argument are the same truth value
|
|
191 |
(since the receiver is false, return true if the argument is also false)"
|
|
192 |
|
|
193 |
^ aBoolean not
|
|
194 |
!
|
|
195 |
|
9000
|
196 |
implies:aBoolean
|
|
197 |
"return true if receiver => argument"
|
|
198 |
|
|
199 |
^ true
|
|
200 |
!
|
|
201 |
|
574
|
202 |
not
|
|
203 |
"return true, if the receiver is false, false otherwise
|
3044
|
204 |
(since the receiver is false, return true).
|
|
205 |
Notice:
|
|
206 |
This method is open coded (inlined) by the compiler(s)
|
|
207 |
- redefining it may not work as expected."
|
574
|
208 |
|
|
209 |
^ true
|
|
210 |
!
|
|
211 |
|
|
212 |
xor:aBoolean
|
|
213 |
"return true, if the receiver and the argument are different truth values
|
|
214 |
(since the receiver is false, return true, if the armument is not false)"
|
|
215 |
|
|
216 |
^ aBoolean
|
|
217 |
!
|
|
218 |
|
|
219 |
| aBoolean
|
|
220 |
"return true, if either the receiver or the argument is true
|
6906
|
221 |
(since the receiver is false, return the argument).
|
|
222 |
Notice:
|
|
223 |
as this is a binary message, the argument is always evaluated.
|
|
224 |
It might be better to use or:[...], which does not evaluate
|
|
225 |
the argument if the receiver is already true."
|
574
|
226 |
|
|
227 |
^ aBoolean
|
|
228 |
! !
|
|
229 |
|
|
230 |
!False methodsFor:'printing & storing'!
|
1
|
231 |
|
|
232 |
printString
|
54
|
233 |
"return character sequence representing the receiver"
|
1
|
234 |
|
|
235 |
^ 'false'
|
|
236 |
! !
|
2
|
237 |
|
692
|
238 |
!False class methodsFor:'documentation'!
|
|
239 |
|
|
240 |
version
|
19112
|
241 |
^ '$Header$'
|
6906
|
242 |
! !
|
19112
|
243 |
|