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