Subject: [clisp-list] READ-BYTE-ARRAY now accepts :NO-HANG keyword argument + RFE: how much could ext:convert-from-string process?

From: "Hoehle, Joerg-Cyril" <[email-masked]>
Date: Mon Jan 27 02:30:02 2003

Hi,

Sam wrote:
>when you call READ-BYTE-ARRAY with :NO-HANG T and the sequence being a
>(VECTOR (UNSIGNED-BYTE 8)), it performs at most one read(2) call and
>returns whatever is available:
There's progress.

No-hang is misleading, as it depends on the programmer having set non-blocking-mode on this socket. This is not strictly necessary when using select()/poll() loops. The call may well hang.

I believe the next thing that people will ask for is how to deal with multibyte encodings.

I think that EXT:CONVERT-STRING-FROM-BYTES should return an extra value (like PARSE-INTEGER) to indicate whether it could process everything (NIL, as for typical :END convention) or stopped earlier (index, as in PARSE-INTEGER, usable as :END or :START) because it hit an incomplete character.

So people could combine partial (or no-hang) reads and conversion to characters and produce correct sequences.

Note that this does not solve CRLF issues. Converting "A<CR>" can be considered complete (Mac style), but processing the following "<LF>B<CR><LF>" must not yield two lines.

>a similar interface to write(2), i.e., WRITE-BYTE-SEQUENCE :NO-HANG,
>is trickier: it is not clear how WRITE-BYTE-SEQUENCE should indicate
>incomplete output.  maybe an extra return value?
Sounds reasonable.
>or maybe make it always return the same as READ-BYTE-ARRAY -
>the number of elements processed?
That's too late, as this function has been available for many years and documented as returning the sequence. An extra value is the only option. Unless you introduce a new function, which is not your favourite choice (you prefer adding keywords).

Regards,
	Jorg Hohle.

---

From: Sam Steingold <[email-masked]>
Date: Tue Jan 28 17:55:11 2003

> * In message <[email-masked]>
> * On the subject of "[clisp-list] READ-BYTE-ARRAY now accepts :NO-HANG keyword argument + RFE: how much could ext:convert-from-string process?"
> * Sent on Mon, 27 Jan 2003 11:27:00 +0100
> * Honorable "Hoehle, Joerg-Cyril" <[email-masked]> writes:
>
> Sam wrote:
> No-hang is misleading, as it depends on the programmer having set
> non-blocking-mode on this socket.

it does not.

> I believe the next thing that people will ask for is how to deal with
> multibyte encodings.  I think that EXT:CONVERT-STRING-FROM-BYTES
> should return an extra value (like PARSE-INTEGER) to indicate whether
> it could process everything (NIL, as for typical :END convention) or
> stopped earlier (index, as in PARSE-INTEGER, usable as :END or :START)
> because it hit an incomplete character.

sounds reasonable.
I defer this to Bruno.

> That's too late, as this function has been available for many years
> and documented as returning the sequence. An extra value is the only
> option. Unless you introduce a new function, which is not your
> favourite choice (you prefer adding keywords).

returning the string is broken (and useless).
do people use WRITE-BYTE-SEQUENCE directly?
(as opposed to WRITE-SEQUENCE)

-- 
Sam Steingold (http://www.podval.org/~sds) running RedHat8 GNU/Linux
<http://www.camera.org> <http://www.iris.org.il> <http://www.memri.org/>
<http://www.mideasttruth.com/> <http://www.palestine-central.com/links.html>
The paperless office will become a reality soon after the paperless toilet.