#100 closed defect (fixed)
STREAM-FILE-POSITION fails when invoked with a Gray stream
Reported by: | Anton Vodonosov | Owned by: | Raymond Toy |
---|---|---|---|
Priority: | critical | Milestone: | |
Component: | Gray-streams | Version: | 2014-05 |
Keywords: | Cc: |
Description
Even after you did (require :gray-streams), if you pass a Gray stream to cl:file-position, you get an error:
#<TRIVIAL-GRAY-STREAMS-TEST::TEST-STREAM {5902550D}> is an unsupported Gray stream.
You can see this error at the bottom of a trivial-gray-streams test suite: http://cl-test-grid.appspot.com/blob?key=eefx5t0o0r
BTW, this blocks as important library as drakma. (Old mailing list thread about this: https://www.mail-archive.com/cmucl-help-bounce@cons.org/msg03368.html, this error happens when drakma calls cl:file-position)
Change History (8)
comment:1 Changed 10 years ago by
Component: | Core → Gray-streams |
---|---|
Owner: | changed from somebody to Raymond Toy |
Priority: | major → critical |
comment:2 Changed 10 years ago by
comment:3 Changed 10 years ago by
The Gray proposal was made before the standard was finalized, and was based on Common Lisp The Language.
The book does not have cl:file-position function, that's why (I think) the Gray proposal does not have stream-file-position. The same situation with cl:write-sequence, cl:read-sequence - they are absent in the book, and have no counterparts in the Gray proposal.
But all lisps provide gray methods for these functions. CMUCL in particular, has ext:stream-read-sequence. It is logical - Gray stream should behave as a replacement for a built-in streams; if we have some code that accepts a stream as a parameter, we should be able to pass a Gray stream as well as a built-in stream.
BTW, it is funny to see how diverged the stream-read/write-sequence become in absence of a public specification: https://github.com/trivial-gray-streams/trivial-gray-streams/blob/master/streams.lisp. You can see that CLISP provides stream-read-byte-sequence, stream-write-byte-sequence, stream-read-char-sequence, stream-write-char-sequence. CCL provides stream-read-vector, stream-write-vector, stream-read-list, stream-write-list :)
So, please don't be very exotic when you provide STREAM-FILE-POSITION. Desirably, similar to some other lisp.
comment:4 Changed 10 years ago by
Submitted a CCL ticket to make their ccl::stream-position generic Gray function public - http://trac.clozure.com/ccl/ticket/1212
comment:5 Changed 10 years ago by
Ah, yes, and please keep in mind:
- support is needed for both querying file position and changing it
- don't forget to provide default (no-op) implementation for both cases
comment:6 Changed 10 years ago by
Thanks for the info. Very nice.
I'll try to get something in. I won't make it too exotic. :-)
comment:8 Changed 10 years ago by
Thanks for the fix.
I opened a ticket for trivial-gray-streams to use ext:stream-file-position on CMUCL: https://github.com/trivial-gray-streams/trivial-gray-streams/issues/3
I have no problems adding support for this, but I can't find any reference that
file-position
needs to support Gray streams. Do you have such a reference. CCL doesn't seem to list it in their docs. The cliki entry for Gray streams doesn't link to any reference that saysfile-position
is supported.A link would be useful.