aboutsummaryrefslogtreecommitdiff
path: root/std/prelude/booleans.pk
diff options
context:
space:
mode:
authorJJ2024-05-10 01:00:01 +0000
committerJJ2024-05-10 02:41:52 +0000
commit073c902a31936c2b53d89245662fb272c9670169 (patch)
treea8789ed4561dc4c3dde84489a600272cbd5f806b /std/prelude/booleans.pk
parent51c8b349a77a8d8b1b34ce8e03518dad6e3cba00 (diff)
std: sweeping changes.
- replace interfaces with classes - replace : with then and do - solidify memory management as rust-style ownership - replace unsafe blocks with safe/unsafe attributes - add magic and copy attributes - switch Coerce impl from from to to
Diffstat (limited to 'std/prelude/booleans.pk')
-rw-r--r--std/prelude/booleans.pk39
1 files changed, 13 insertions, 26 deletions
diff --git a/std/prelude/booleans.pk b/std/prelude/booleans.pk
index bd81925..e92eac8 100644
--- a/std/prelude/booleans.pk
+++ b/std/prelude/booleans.pk
@@ -4,39 +4,26 @@
pub type unit = union[sole]
pub type bool = union[false, true]
-# note: puck could resolve kleene.false vs bool.false...
-# this is probably not worth it compared to improved type inference
-# pub type Kleene = union[False, Maybe, True]
-
## Boolean equality
-pub func ==(a: bool, b: bool): bool =
- match a
- of (true, true), (false, false): true
- of (false, true), (true, false): false
+@[magic]
+pub func ==(a: bool, b: bool): bool
-pub func !=(a: bool, b: bool): bool =
- not a == b
+## Boolean inequality
+@[magic]
+pub func !=(a: bool, b: bool): bool
## Boolean negation
-pub func not(a: bool): bool =
- match a
- of true: false
- of false: true
+@[magic]
+pub func not(a: bool): bool
## Boolean conjunction
-pub func and(a: bool, b: bool): bool =
- match (a, b)
- of (true, true): true
- of _: false
+@[magic]
+pub func and(a: bool, b: bool): bool
## Boolean disjunction
-pub func or(a: bool, b: bool): bool =
- match (a, b)
- of (false, false): false
- of _: true
+@[magic]
+pub func or(a: bool, b: bool): bool
## Boolean exclusive disjunction
-pub func xor(a: bool, b: bool): bool =
- match (a, b)
- of (true, true), (false, false): false
- of (true, false), (false, true): true
+@[magic]
+pub func xor(a: bool, b: bool): bool