[@FroMage] We’d like to have a Byte
type, even though the traditional bit operators have been stolen by Set
. We can probably do with methods for now until by popular request we get them back when everyone realises Set
doesn’t need them.
We’re prefer unsigned bytes, which might not be hard to do because the only time we notice that bytes are signed in Java is when doing arithmetic (and our Byte
type will not be a Numeric
so we’re good), when printing (which we can also fix) and when converting to a number (we can fix that too).
We might want to try to unify Byte
with Java’s BitSet
, since the former is a fixed-length 8 bit version of the latter. It might even be possible to optimise BitSet
operations for native underlying types of corresponding size, such as byte
or long
.
This is for post-M2.
[Migrated from ceylon/ceylon-spec#183] [Closed at 2014-07-23 10:07:44]
Issue Analytics
- State:
- Created 12 years ago
- Comments:101
[@FroMage] I don’t know what else to add, really. I showed you we already have code that wants to compare bytes, and that it appears to be a common thing to do, and you talk about congruence class. I propose we 1/ make bytes comparable, and 2/ we ban anybody who knows what the fuck a congruence class is from ever using bytes.
[@lucaswerkmeister]
Eh… in Germany at least, they teach it to us in the first semester of CS studies, so that excludes a lot of people 😃 it’s not that complicated, and Gavin is completely right: Putting some comparison on a type where
x.successor > x
is sometimes true and sometimes false, and127.byte < 128.byte
could mean either127 < 128
(true) or127 < -128
(false)is crazy.
But if we have the
signedInteger
andunsignedInteger
attributes, why is(-1).byte
not allowed and255
is allowed? That’s an arbitrary bias to the unsigned representation IMO, whereas I think both representations should be of equal “value”. (Of course, makingByte
sComparable
would also introduce this bias.)