larcenists / larceny

Larceny Scheme implementation
Other
202 stars 32 forks source link

procedure requested: string-output-port? #772

Closed WillClinger closed 8 years ago

WillClinger commented 8 years ago

As Ken Dickey said: "It would be useful to test an output-port to see if get-output-string can be applied."

That procedure is defined in src/Lib/Common/stringio.sch but isn't available at the R5RS top level.

This temporary workaround is extremely representation-dependent and might break in future versions of Larceny, but it works in v0.99:

(import (primitives vector-like-ref))

(define port.iodata 7)    ; ouch

(define (string-output-port? port)
  (and (output-port? port)
       (let ((d (vector-like-ref port port.iodata)))
         (and (vector? d)
              (> (vector-length d) 0)
              (eq? (vector-ref d 0) 'string-output-port)))))
WillClinger commented 8 years ago

Accomplished by changeset 0cec8f6ee6689a8153cdbf9d71930a56388e1338