aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordos-reis <gdr@axiomatics.org>2008-10-02 08:25:16 +0000
committerdos-reis <gdr@axiomatics.org>2008-10-02 08:25:16 +0000
commit907c99892d8f10115d9e15169ce6e76f5e61d0ce (patch)
tree1748e0458c422c8d10195d1d3a87f0e95f7ef63f /src
parent6d8d9ff0d92a31b78b03b669b5ad99ef0b2715f4 (diff)
downloadopen-axiom-907c99892d8f10115d9e15169ce6e76f5e61d0ce.tar.gz
* algebra/data.spad.pamphlet (Byte): Add coercion to and from
Character.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog5
-rw-r--r--src/algebra/data.spad.pamphlet32
2 files changed, 20 insertions, 17 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 70fc6021..3fd40052 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,8 @@
+2008-10-02 Gabriel Dos Reis <gdr@cs.tamu.edu>
+
+ * algebra/data.spad.pamphlet (Byte): Add coercion to and from
+ Character.
+
2008-10-01 Gabriel Dos Reis <gdr@cs.tamu.edu>
* interp/i-spec1.boot (upcase): Tidy.
diff --git a/src/algebra/data.spad.pamphlet b/src/algebra/data.spad.pamphlet
index fff04339..b491d001 100644
--- a/src/algebra/data.spad.pamphlet
+++ b/src/algebra/data.spad.pamphlet
@@ -23,46 +23,44 @@ import OutputForm
++ Description:
++ Byte is the datatype of 8-bit sized unsigned integer values.
Byte(): Public == Private where
- Public == Join(OrderedSet, CoercibleTo NonNegativeInteger) with
+ Public == Join(OrderedSet, CoercibleTo NonNegativeInteger,
+ CoercibleTo Character) with
byte: NonNegativeInteger -> %
++ byte(x) injects the unsigned integer value `v' into
++ the Byte algebra. `v' must be non-negative and less than 256.
coerce: NonNegativeInteger -> %
++ coerce(x) has the same effect as byte(x).
+ coerce: Character -> %
+ ++ coerce(c) views `c' a a byte. In particular `c' is supposed
+ ++ to have a numerical value less than 256.
bitand: (%,%) -> %
++ bitand(x,y) returns the bitwise `and' of `x' and `y'.
bitior: (%,%) -> %
++ bitor(x,y) returns the bitwise `inclusive or' of `x' and `y'.
Private == add
+ import Character
byte(x: NonNegativeInteger): % ==
not (x < 256$Lisp) =>
userError "integer value cannot be represented by a byte"
x : %
- hash x ==
- SXHASH(x)$Lisp
+ hash x == SXHASH(x)$Lisp
- coerce(x: NonNegativeInteger): % ==
- byte x
+ coerce(x: NonNegativeInteger): % == byte x
+ coerce(x: %): NonNegativeInteger == x : NonNegativeInteger
- coerce(x: %): NonNegativeInteger ==
- x : NonNegativeInteger
+ coerce(c: Character) == ord(c)::%
+ coerce(x: %): Character == char(x::NonNegativeInteger)
coerce(x: %): OutputForm ==
x::NonNegativeInteger::OutputForm
- x = y ==
- byteEqual(x,y)$Lisp
-
- x < y ==
- byteLessThan(x,y)$Lisp
-
- bitand(x,y) ==
- bitand(x,y)$Lisp
+ x = y == byteEqual(x,y)$Lisp
+ x < y == byteLessThan(x,y)$Lisp
- bitior(x,y) ==
- bitior(x,y)$Lisp
+ bitand(x,y) == bitand(x,y)$Lisp
+ bitior(x,y) == bitior(x,y)$Lisp
@