From: Kaelin Colclasure
Subject: What's the "right" :element-type ...
Date: 
Message-ID: <r2iJ3.566$4z.72916@newsin1.ispchannel.com>
... for an array which I expect to contain binary data which
must be passed unmolested to a foreign function? I have resorted
to using 'character in my code, but I can't help but think this is
going to bite me at some point.

I confess that I'm having a hard time understanding the rationale
behind #'byte and friends in Common Lisp. It seems you cannot use
(byte 8 0) as a type, and (at least in ACL) types that *look* like
they should do the right thing (e.g. 'unsigned-byte) result in an
array of fixnums -- not what I had in mind.

-- Kaelin
From: Pekka P. Pirinen
Subject: Re: What's the "right" :element-type ...
Date: 
Message-ID: <ixu2o7w2yu.fsf@gaspode.cam.harlequin.co.uk>
"Kaelin Colclasure" <······@everest.com> writes:
> ... for an array which I expect to contain binary data which
> must be passed unmolested to a foreign function? I have resorted
> to using 'character in my code, but I can't help but think this is
> going to bite me at some point.

Sounds like half a question.  Why doesn't the semantics of the data
tell you what the type is?  You're right that CHARACTER is too rich,
and certainly non-portable.  If the data is some kind of integers, one
of the integer types should be the answer.

> I confess that I'm having a hard time understanding the rationale
> behind #'byte and friends in Common Lisp. It seems you cannot use
> (byte 8 0) as a type,

It's not a type, it's a function that returns bytespecs to be used
with LDB &co.  You want SIGNED-BYTE or UNSIGNED-BYTE (which are just
abbreviations of common INTEGER subtypes).

> and (at least in ACL) types that *look* like
> they should do the right thing (e.g. 'unsigned-byte) result in an
> array of fixnums -- not what I had in mind.

CL implementations do not have separate array types for each element
type, they "upgrade" the element type to the nearest supertype they
have an array type for.  See UPGRADED-ARRAY-ELEMENT-TYPE and Franz doc
for arrays.  Note that some Lisps have poor implementations of
UPGRADED-ARRAY-ELEMENT-TYPE that are sensitive to how you express the
type and give different results for equivalent typespecs -- I don't
know how Franz does.  I suspect ACL would have an array type for
unsigned 8-bit bytes, for example; try (UNSIGNED-BYTE 8).
-- 
Pekka P. Pirinen
Adaptive Memory Management Group, Harlequin Limited
Those who do not understand Lisp are doomed to reimplement it.
  - Erik Naggum <erik_naggum.no>