[Openmcl-devel] write-sequence

Gary Byers gb at clozure.com
Wed May 28 09:35:23 PDT 2003



On Wed, 28 May 2003, Sven Van Caekenberghe wrote:

> Isn't (write-sequence "foo" *standard-output*) supposed to just work ?
> This is an example from the HyperSpec. It would be nice if T would also
> be accepted ;-) - but that has probably to do with method dispatch.
>

On the second point: I can't think of a good reason for WRITE-SEQUENCE
not to be extended to accept an "output stream designator"; unlike
most other output functions, it's defined to merely accept an "output
stream".


> ? (write-sequence "foo" *standard-output*)
>  > Error: No applicable method for args:
>  >         (#<SYNONYM-STREAM to *TERMINAL-IO* #x529BE5E> "foo" :START 0
> :END 3)
>  >         to #<STANDARD-GENERIC-FUNCTION CCL::STREAM-WRITE-SEQUENCE
> #x50D5CF6>
>  > While executing: #<CCL::STANDARD-KERNEL-METHOD NO-APPLICABLE-METHOD
> (T)>
>  > Type :POP to abort.
> Type :? for other options.
> 1 >
>

This was simply botched some time ago (when STREAM-WRITE-SEQUENCE was
introduced, effectively replacing STREAM-WRITE-LIST and STREAM-WRITE-VECTOR
as the Gray streams interfaces to WRITE-SEQUENCE.)  All of the composite
stream classes (SYNONYM-STREAM, TWO-WAY-STREAM, CONCATENATED-STREAM, etc.)
have to implement methods on STREAM-WRITE-SEQUENCE that dispatch in the
direction of an underlying OUTPUT-STREAM, e.g.:

(defmethod stream-write-sequence ((stream two-way-stream) seq
                                  &key start end)
  (stream-write-sequence (two-way-stream-output-stream stream)
      seq :start start :end end))

(defmethod stream-write-sequence ((stream synonym-stream) seq
                                  &key start end)
  (stream-write-sequence (symbol-value (synonym-stream-symbol stream))
      seq :start start :end end))

and similarly for CONCATENATED-STREAM, BROADCAST-STREAM, etc.

All of this tedium would be worthwhile if (by the time we actually
got to an interesting class of OUTPUT-STREAM) the implementor of
the method for that interesting class didn't have to determine
if the start and end arguments were sane, if the "seq" argument was
really a sequence and what kind it was, whether or not it's a
(SIMPLE-ARRAY * (*)) if it's a vector, etc.

I don't think too highly of STREAM-WRITE-SEQUENCE/STREAM-READ-SEQUENCE
(as you may have guessed), but I suppose that that isn't a good argument
for not having the composite stream classes understand them.  Before
trying to decide what the right fix is, does anyone use STREAM-WRITE-
SEQUENCE/STREAM-READ-SEQUENCE and find them useful ?  Would anyone
miss them if they were removed/deprecated with extreme prejudice ?


> On the other hand, (write-char #\A *standard-output*) and (write-char
> #\A t) do work.
>
> Sven
>
>
> _______________________________________________
> Openmcl-devel mailing list
> Openmcl-devel at clozure.com
> http://clozure.com/cgi-bin/mailman/listinfo/openmcl-devel
>
>

_______________________________________________
Openmcl-devel mailing list
Openmcl-devel at clozure.com
http://clozure.com/cgi-bin/mailman/listinfo/openmcl-devel



More information about the Openmcl-devel mailing list