[Openmcl-devel] duplicating a stream

Pascal J. Bourguignon pjb at informatimago.com
Mon Mar 26 14:48:48 PDT 2012


"Pascal J. Bourguignon" <pjb at informatimago.com> writes:

> When calling run-program, one need to pass a :shared stream.
>
> Since I may get non shared file streams (by default they're :private),
> I'd want to "duplicate" the stream, making a shared stream to give to
> run-program, using the same stream-device:
>
>   (defun wrap-stream (direction stream)
>     ;; Since stream may not be shared, we make a new stream for
>     ;; the process.
>     (typecase stream
>       (stream     (ccl::make-basic-stream-instance
>                    (if (eql :input direction)
>                        'file-character-input-stream
>                        'file-character-output-stream)
>                    :stream-device (ccl::stream-device stream direction)
>                    :direction direction
>                    :element-type 'character
>                    :sharing :lock
>                    :encoding ccl:*default-file-character-encoding*
>                    :line-termination #+windows :windows #-windows :unix
>                    :auto-close t))
>       (otherwise  stream)))
>
> Unfortunately that fails with:
>
>     There is no applicable method for the generic function:
>       #<standard-generic-function ccl:class-own-wrapper #x302000032F0F>
>     when called with arguments:
>       (com.informatimago.run-program::file-character-output-stream)
>        [Condition of type simple-error]
>
> What did I do wrong?

I used the wrong class name, but I get the same error with the right
class name:

  (defun wrap-stream (direction stream)
    ;; Since stream may not be shared, we make a new stream for
    ;; the process.
    (typecase stream
      (stream     (ccl::make-basic-stream-instance
                   (if (eql :input direction)
                       'ccl::file-character-input-stream
                       'ccl::file-character-output-stream)
                   :stream-device (ccl::stream-device stream direction)
                   :direction direction
                   :element-type 'character
                   :sharing :lock
                   :encoding ccl:*default-file-character-encoding*
                   :line-termination #+windows :windows #-windows :unix
                   :auto-close t))
      (otherwise  stream)))


  There is no applicable method for the generic function:
    #<standard-generic-function ccl:class-own-wrapper #x302000032C1F>
  when called with arguments:
    (ccl::file-character-output-stream)
     [Condition of type simple-error]

-- 
__Pascal Bourguignon__                     http://www.informatimago.com/
A bad day in () is better than a good day in {}.




More information about the Openmcl-devel mailing list