aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
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
@