close Warning: Can't synchronize with repository "(default)" ("(default)" is not readable or not a Git repository.). Look in the Trac log for more information.

Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#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 Anton Vodonosov

Component: CoreGray-streams
Owner: changed from somebody to Raymond Toy
Priority: majorcritical

comment:2 Changed 10 years ago by Raymond Toy

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 says file-position is supported.

A link would be useful.

comment:3 Changed 10 years ago by Anton Vodonosov

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 Anton Vodonosov

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 Anton Vodonosov

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 Raymond Toy

Thanks for the info. Very nice.

I'll try to get something in. I won't make it too exotic. :-)

comment:7 Changed 10 years ago by Raymond Toy

Resolution: fixed
Status: newclosed

Fixed in 9e687a

comment:8 Changed 10 years ago by Anton Vodonosov

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

Note: See TracTickets for help on using tickets.