[Ecls-list] Sequence streams

Matthew Mondor mm_lists at pulsar-zone.net
Sun Aug 28 00:22:35 UTC 2011


On Sat, 27 Aug 2011 17:32:26 +0200
Juan Jose Garcia-Ripoll <juanjose.garciaripoll at googlemail.com> wrote:

>  - Implemented SEQUENCE-STREAMs, which are input/output streams defined on
> some
>    specialized array type. The functions to create them are
>      (ext:make-sequence-input-stream vector &key :start :end
> :external-format)
>      (ext:make-sequence-output-stream vector &key :external-format)

Awesome!

However when trying it I ran into a problem here, I'm not sure if I'm
missing something or if it's a bug:


(setf *bytes*
      (make-array 16
                  :element-type '(unsigned-byte 8)
                  :fill-pointer 0))
;;; -> #()

(with-open-stream
    (s (ext:make-sequence-output-stream *bytes*
                                        :external-format :utf-8))
  (write-string "Héhéhéhé~%" s)
  *bytes*)
;;; -> #(72 195 169 104 195 169 104 195 169 104 195 169 126 37) as expected

(with-open-stream
    (s (ext:make-sequence-input-stream *bytes*
                                       :external-format :utf-8))
  (read-line s))
;;; -> "HHHHHHHHHHHHHH" T	I would have expected	"Héhéhéhé
							"


I then tried the inverse to convert the bytes back:


(setf *string*
               (make-array 16
                           :element-type 'character
                           :fill-pointer 0))
;;; -> ""

(with-open-stream
    (s (ext:make-sequence-output-stream *string*))
  (loop
     for b across *bytes*
     do
       (write-byte b s))
  *string*)

;;; -> Crashes SLIME (ECL remains running, but *STRING* contains illegal chars,
;;;    and (schar *string* <n>) can yield segmentation fault signals.
;;;	I also try with various settings of :external-format


Thanks,
-- 
Matt




More information about the ecl-devel mailing list