From: Peter Seibel
Subject: sequence-[input|output]-stream?
Date: 
Message-ID: <m33clbjb2v.fsf@localhost.localdomain>
Is there any way to make a stream like a string-input-stream except on
top of a sequence of bytes (octets) rather than a string? I.e. I want
the stream-element-type to be (unsigned-byte 8).

-Peter

-- 
Peter Seibel                                      ·····@javamonkey.com

  The intellectual level needed   for  system design is  in  general
  grossly  underestimated. I am  convinced  more than ever that this
  type of work is very difficult and that every effort to do it with
  other than the best people is doomed to either failure or moderate
  success at enormous expense. --Edsger Dijkstra

From: Duane Rettig
Subject: Re: sequence-[input|output]-stream?
Date: 
Message-ID: <4znnjxbok.fsf@beta.franz.com>
Peter Seibel <·····@javamonkey.com> writes:

> Is there any way to make a stream like a string-input-stream except on
> top of a sequence of bytes (octets) rather than a string? I.e. I want
> the stream-element-type to be (unsigned-byte 8).

Simple streams
(http://www.franz.com/support/documentation/6.2/doc/streams.htm)
defines "buffer" streams, like string streams, which have this
characteristic.  Also to parallel string streams, you can use
make-buffer-input-stream, make-buffer-output-stream, and the
macros with-input-from-buffer and with-output-to-buffer, linked to from
http://www.franz.com/support/documentation/6.2/doc/streams.htm#ex-interface-funs-2
as well.

And since simple-streams are bivalent, you can do both read-char and
read-byte on the input stream, or write-char and write-byte on the
output stream.

-- 
Duane Rettig    ·····@franz.com    Franz Inc.  http://www.franz.com/
555 12th St., Suite 1450               http://www.555citycenter.com/
Oakland, Ca. 94607        Phone: (510) 452-2000; Fax: (510) 452-0182   
From: Peter Seibel
Subject: Re: sequence-[input|output]-stream?
Date: 
Message-ID: <m3y933hw88.fsf@localhost.localdomain>
Peter Seibel <·····@javamonkey.com> writes:

> Is there any way to make a stream like a string-input-stream except on
> top of a sequence of bytes (octets) rather than a string? I.e. I want
> the stream-element-type to be (unsigned-byte 8).

To answer my own question, I take it from the fact that ACL has an
extension, make-buffer-output-tream and make-buffer-input-tream, which
seems to be exactly what I'm looking for that such a thing is not part
of standard Common Lisp. Do other Lisps have equivalent functionality?

-Peter

-- 
Peter Seibel                                      ·····@javamonkey.com

  The intellectual level needed   for  system design is  in  general
  grossly  underestimated. I am  convinced  more than ever that this
  type of work is very difficult and that every effort to do it with
  other than the best people is doomed to either failure or moderate
  success at enormous expense. --Edsger Dijkstra
From: Duane Rettig
Subject: Re: sequence-[input|output]-stream?
Date: 
Message-ID: <4vfy7xa8h.fsf@beta.franz.com>
Peter Seibel <·····@javamonkey.com> writes:

> Peter Seibel <·····@javamonkey.com> writes:
> 
> > Is there any way to make a stream like a string-input-stream except on
> > top of a sequence of bytes (octets) rather than a string? I.e. I want
> > the stream-element-type to be (unsigned-byte 8).
> 
> To answer my own question, I take it from the fact that ACL has an
> extension, make-buffer-output-tream and make-buffer-input-tream, which
> seems to be exactly what I'm looking for that such a thing is not part
> of standard Common Lisp. Do other Lisps have equivalent functionality?

They would if they implemented simple-streams.  I've been hoping that
people would start to adopt simple-streams for their implementations,
but so far the only bites I've gotten have been nibbles, other than the
work Paul Foley did to start putting simple-streams onto CMUCL
(http://users.actrix.co.nz/mycroft/cl.htm).

-- 
Duane Rettig    ·····@franz.com    Franz Inc.  http://www.franz.com/
555 12th St., Suite 1450               http://www.555citycenter.com/
Oakland, Ca. 94607        Phone: (510) 452-2000; Fax: (510) 452-0182   
From: Joerg Hoehle
Subject: Re: sequence-[input|output]-stream?
Date: 
Message-ID: <u3cl8u305.fsf@dont.t-systems.UCE.spam.no.com>
Duane Rettig <·····@franz.com> writes:
> Peter Seibel <·····@javamonkey.com> writes:
> > Peter Seibel <·····@javamonkey.com> writes:
> > > Is there any way to make a stream like a string-input-stream except on
> > > top of a sequence of bytes (octets) rather than a string? I.e. I want

> > To answer my own question, I take it from the fact that ACL has an
> > extension, make-buffer-output-tream and make-buffer-input-tream, which
> > seems to be exactly what I'm looking for that such a thing is not part
> > of standard Common Lisp. Do other Lisps have equivalent functionality?

> They would if they implemented simple-streams.  I've been hoping that
> people would start to adopt simple-streams for their implementations,
> but so far the only bites I've gotten have been nibbles,

I'd wish CLISP would have them as well, because I feel (never actually
tried out) that they solve quite some problems[*], but that means yet
another rewrite of CLISP's huge streams stuff.

A faster solution for the OP's wish may be to make CLISP's
EXT:MAKE-STRING-INPUT-STREAM and output sibling accept (SETF
STREAM-ELEMENT-TYPE) like CLISP's file/pipe streams and use that, or
just provide the equivalent for octet streams under distinct names, or
just have READ-CHAR/BYTE check ARRAY-ELEMENT-TYPE of the underlying
buffer array: that would be much less new/changed code in CLISP and
IMHO easy to add.

So best wishes to simple-streams (although I did not understand the
lower-layer simple-stream description on Allegro's site, last time I
looked at it - hint, hint).

Regards,
	Jorg Hohle
Telekom/T-Systems Technology Center

[*] E.g. typical CRLF translations issues, well-defined availability
of something to read vs. a full-character to read, turning bytes into
characters and other issues discussed here now and then.
From: Duane Rettig
Subject: Re: sequence-[input|output]-stream?
Date: 
Message-ID: <44r5o8was.fsf@beta.franz.com>
Joerg Hoehle <············@dont.t-systems.UCE.spam.no.com> writes:

> So best wishes to simple-streams (although I did not understand the
> lower-layer simple-stream description on Allegro's site, last time I
> looked at it - hint, hint).

Well, this hint has been given many times before, not the first of
which came externally.  The original document was more of a spec, and
doesn't read well as a description or a tutorial.  For this reason,
I developed the tutorial I gave at ILC 2002, and have posted the
availability of the Powerpoint presentation once or twice here.  Here
it is again, in case you didn't get it:

ftp://ftp.franz.com/pub/duane/Simp-stms.ppt

You should go through it using the "Notes Page" view.  I wrote
extensive notes on it, so it won't just be a matter of looking
at bulleted items.

-- 
Duane Rettig    ·····@franz.com    Franz Inc.  http://www.franz.com/
555 12th St., Suite 1450               http://www.555citycenter.com/
Oakland, Ca. 94607        Phone: (510) 452-2000; Fax: (510) 452-0182   
From: Andreas Eder
Subject: Re: sequence-[input|output]-stream?
Date: 
Message-ID: <m3ptoaz89o.fsf@elgin.eder.de>
Duane Rettig <·····@franz.com> writes:

> They would if they implemented simple-streams.  I've been hoping that
> people would start to adopt simple-streams for their implementations,
> but so far the only bites I've gotten have been nibbles, other than the
> work Paul Foley did to start putting simple-streams onto CMUCL
> (http://users.actrix.co.nz/mycroft/cl.htm).

Actually it is http://users.actrix.co.nz/mycroft/cl.html

Andreas
-- 
Wherever I lay my .emacs, there�s my $HOME.