From: Karol Skocik
Subject: SBCL, array-element-type and array unboxing
Date: 
Message-ID: <1140885858.024009.199600@t39g2000cwt.googlegroups.com>
Hello,
  I have problems with not understanding the types of elements in array
properly.
There is a function in SBCL socket-receive which starts like this :
(defmethod socket-receive ((socket socket) buffer length ... other args
...
   (with-sockaddr-for (socket sockaddr)
    (let ((flags
           (logior (if oob sockint::MSG-OOB 0) ... other flags ...
      (unless (or buffer length) (error "Must supply at least one of
BUFFER or LENGTH"))
      (unless length (setf length (length buffer)))
      (when buffer (setf element-type (array-element-type buffer)))
      (unless (or (subtypep element-type 'character)
                  (subtypep element-type 'integer))
        (error "Buffer element-type must be either a character or an
integer subtype."))
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

My problem is, that I can't supply any array into socket-receive where
this :
(unless (or (subtypep element-type 'character)
                  (subtypep element-type 'integer))
will be ok.

My arrays always have (array-element-type buffer) => T

TACTIX> (let ((a (make-array 10 :element-type 'unsigned-byte
:initial-element (the unsigned-byte 0))))
	  (declare (type (array unsigned-byte) a))
	  (array-element-type a))
T

So how to do that array-element-type returns unsigned-byte as type of
its elements?

Also, since I want to make this thing fast, I would be happy if I could
receive the bytes into the continuous block of memory (unboxed?) and
not into array of references to bytes...

Thanks for any ideas,
  Karol

From: Zach Beane
Subject: Re: SBCL, array-element-type and array unboxing
Date: 
Message-ID: <m3hd6n5pjj.fsf@unnamed.xach.com>
"Karol Skocik" <············@gmail.com> writes:

> My arrays always have (array-element-type buffer) => T
> 
> TACTIX> (let ((a (make-array 10 :element-type 'unsigned-byte
> :initial-element (the unsigned-byte 0))))
> 	  (declare (type (array unsigned-byte) a))
> 	  (array-element-type a))
> T
> 
> So how to do that array-element-type returns unsigned-byte as type of
> its elements?

(make-array 10 :element-type '(unsigned-byte 8)) for example.

See also UPGRADED-ARRAY-ELEMENT-TYPE.

Zach
From: Karol Skocik
Subject: Re: SBCL, array-element-type and array unboxing
Date: 
Message-ID: <1140887842.405261.293680@u72g2000cwu.googlegroups.com>
Thanks that is!