Boolean

From Erights

(Difference between revisions)
Jump to: navigation, search
(copy in tests from E-on-CL scope-univ.updoc r1044)
Line 1: Line 1:
-
The '''<code>Boolean</code>''' type has exactly two members, <code>false</code> and <code>true</code>. All three of these objects print with those names.
+
The '''<code>Boolean</code>''' type has exactly two members, <code>false</code> and <code>true</code>. All three names are in the [[universal scope]].
-
? true
+
== Protocol ==
-
# value: true
+
-
+
-
? false
+
-
# value: false
+
-
+
-
? boolean
+
-
# value: Boolean
+
-
The [[universal scope]] contains <code>boolean</code> (no capital), <code>false</code>, and <code>true</code>.
+
=== pick/2 ===
-
== Protocol ==
+
pick(<var>t</var>, <var>f</var>) :any
-
 
+
-
{{instance msgdoc|pick|2|<var>t</var>, <var>f</var>|any}}
+
false.pick(<var>t</var>, <var>f</var>) returns <var>f</var>; true.pick(<var>t</var>, <var>f</var>) returns <var>t</var>.
false.pick(<var>t</var>, <var>f</var>) returns <var>f</var>; true.pick(<var>t</var>, <var>f</var>) returns <var>t</var>.
-
? true.pick(1, 2)
+
=== not/0 ===
-
# value: 1
+
 
-
+
not() :Boolean
-
? false.pick(3, 4)
+
-
# value: 4
+
-
 
+
-
{{instance msgdoc|not|0||[[Boolean]]}}
+
Boolean negation.
Boolean negation.
-
? !true
+
=== or/1 ===
-
# value: false
+
-
+
-
? !false
+
-
# value: true
+
-
{{instance msgdoc|or|1|<var>other</var> :[[Boolean]]|[[Boolean]]}}
+
or(<var>other</var> :Boolean) :Boolean
Boolean or. The argument is coerced to a boolean.
Boolean or. The argument is coerced to a boolean.
-
? false | false
+
=== and/1 ===
-
# value: false
+
-
+
-
? false | true
+
-
# value: true
+
-
+
-
? false | def _{to __conformTo(==boolean) :any {return false}}
+
-
# value: false
+
-
+
-
? true | false
+
-
# value: true
+
-
+
-
? true | true
+
-
# value: true
+
-
+
-
? true | -1
+
-
# problem: the int -1 doesn't coerce to a boolean
+
-
+
-
? true | def _{to __conformTo(==boolean) :any {return true}}
+
-
# value: true
+
-
{{instance msgdoc|and|1|<var>other</var> :[[Boolean]]|[[Boolean]]}}
+
and(<var>other</var> :Boolean) :Boolean
Boolean and. The argument is coerced to a boolean.
Boolean and. The argument is coerced to a boolean.
-
? true & true
+
=== xor/1 ===
-
# value: true
+
-
+
-
? true & false
+
-
# value: false
+
-
+
-
? true & def _{to __conformTo(==boolean) :any {return true}}
+
-
# value: true
+
-
+
-
? false & true
+
-
# value: false
+
-
+
-
? false & false
+
-
# value: false
+
-
+
-
? false & -1
+
-
# problem: the int -1 doesn't coerce to a boolean
+
-
+
-
? false & def _{to __conformTo(==boolean) :any {return false}}
+
-
# value: false
+
-
{{XXX}} discuss ideal default wording of coercion failure errors
+
xor(<var>other</var> :Boolean) :Boolean
-
 
+
-
{{instance msgdoc|xor|1|<var>other</var> :[[Boolean]]|[[Boolean]]}}
+
Boolean exclusive or. The argument is coerced to a boolean.
Boolean exclusive or. The argument is coerced to a boolean.
-
? false ^ false
+
=== op__cmp/1 ===
-
# value: false
+
-
+
-
? false ^ true
+
-
# value: true
+
-
+
-
? true ^ def _{to __conformTo(==boolean) :any {return true}}
+
-
# value: false
+
-
+
-
? true ^ false
+
-
# value: true
+
-
+
-
? true ^ true
+
-
# value: false
+
-
+
-
? false ^ -1
+
-
# problem: the int -1 doesn't coerce to a boolean
+
-
+
-
? false ^ def _{to __conformTo(==boolean) :any {return true}}
+
-
# value: true
+
-
=== op__cmp/1 ===
 
Comparison with other Booleans. See [[Message op__cmp]].
Comparison with other Booleans. See [[Message op__cmp]].
-
 
-
{{XXX}} write tests for this
 
-
 
-
[[Category:ELib specification]]
 

Revision as of 19:47, 21 April 2007

The Boolean type has exactly two members, false and true. All three names are in the universal scope.

Contents

Protocol

pick/2

pick(t, f) :any

false.pick(t, f) returns f; true.pick(t, f) returns t.

not/0

not() :Boolean

Boolean negation.

or/1

or(other :Boolean) :Boolean

Boolean or. The argument is coerced to a boolean.

and/1

and(other :Boolean) :Boolean

Boolean and. The argument is coerced to a boolean.

xor/1

xor(other :Boolean) :Boolean

Boolean exclusive or. The argument is coerced to a boolean.

op__cmp/1

Comparison with other Booleans. See Message op__cmp.

Personal tools
more tools