[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.lisp

strange subtype behavior of unsigned-byte

Jim Newton

1/15/2016 3:04:00 PM

I get the same results in sbcl and in clisp, so it seems I'm having a thinko.
It seems that UNSIGNED-BYTE is a subtype of the union of BIGNUM and FIXNUM,
but it is subtype of neither.
This means there is some UNSIGNED-BYTE which is a BIGNUM and some UNSIGNED-BYTE
(maybe the same one, maybe a different one) which is a FIXNUM.

Does anyone understand this?

CL-USER> (subtypep 'unsigned-byte 'bignum)
NIL
T
CL-USER> (subtypep 'unsigned-byte 'fixnum)
NIL
T
CL-USER> (subtypep 'unsigned-byte '(or bignum fixnum))
T
T
2 Answers

Jim Newton

1/15/2016 4:49:00 PM

0

On Friday, January 15, 2016 at 4:03:46 PM UTC+1, Jim Newton wrote:
> This means there is some UNSIGNED-BYTE which is a BIGNUM and some UNSIGNED-BYTE
> (maybe the same one, maybe a different one) which is a FIXNUM.
>
> Does anyone understand this?
>

I understand now, unsigned-byte is not a byte as the name implies, but rather the
degenerate form of a more general type specifier (unsigned-byte s) where s represents the number
of bits. unsigned-byte is the same as (unsigned-byte *) or a positive integer of arbitrarily many bits.
So, yes it is a subtype of both (or bignum fixnum) but not a subset of either.

It is just unfortunate that the name seems to imply one single byte. :-(

Günther Thomsen

1/15/2016 7:07:00 PM

0

On Friday, January 15, 2016 at 8:49:13 AM UTC-8, Jim Newton wrote:

> It is just unfortunate that the name seems to imply one single byte. :-(

As it ought to. You just imply a certain, fixed number of bits in a Byte. That might be understandable now, but 30 years ago, there were at least two different sizes common, hence the 'octet' preferred by GNU utilities (and the French I believe).