[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Gcl-devel] identifying string-streams
From: |
Matt Kaufmann |
Subject: |
Re: [Gcl-devel] identifying string-streams |
Date: |
Thu, 27 Jan 2011 15:43:34 -0600 |
Thanks! If I know that a given stream is either a string-stream or a
stream connected to a file (as opposed to being one of those "other
specialized streams"), then is my workaround OK (without needing your
patch)?
Regards,
Matt
Cc: address@hidden
From: Camm Maguire <address@hidden>
Date: Thu, 27 Jan 2011 14:32:29 -0500
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Greetings!
Alas, in traditional GCL (2.6.8, not 2.7.0), stream type detection
is not fully implemented without workarounds as you suggest. And
indeed there may be other specialized streams with a NIL stream-name
other than string-streams, as this keys off of a multi-purpose slot in
the structure: "object1".
The surest way for now is:
=============================================================================
/tmp/y.l
=============================================================================
(clines "fixnum stream_mode(object sm) {return sm->sm.sm_mode;}")
(defentry stream-mode (object) (fixnum "stream_mode"))
(defun string-stream-p (s)
(and (streamp s)
(let ((s (stream-mode s)))
(or (= s (load-time-value (stream-mode (make-string-input-stream
""))))
(= s (load-time-value (stream-mode
(make-string-output-stream))))))))
=============================================================================
(load (compile-file "/tmp/y.l"))
All these fields are exposed automatically in inlinable lisp and C
functions in the experimental branch, which I'd like to merge into cvs
head soon.
Take care,
Matt Kaufmann <address@hidden> writes:
> Hi --
>
> I'd be grateful if someone can answer the question below, even in the
> negative, but I can work around the issue so please don't spend more
> than a moment on this.
>
> In ANSI Common Lisp, (typep stream 'string-stream) is true when stream
> is connected to a stream (hence not to a file). In non-ANSI GCL, the
> type of such a stream is 'stream, not 'string-stream, and the only way
> I found (after considerable searching) to do such a query is as
> follows:
>
> (si::stream-name stream) appears to return NIL if and only if stream
> is a string-stream.
>
> QUESTION: For non-ANSI GCL, is this correct for both past and future
> versions, or is there a better way to identify string-streams?
>
> Thanks. If there is a different list I should query instead, please
> let me know (and, my apologies).
>
> Regards,
> Matt Kaufmann
>
> _______________________________________________
> Gcl-devel mailing list
> address@hidden
> http://lists.gnu.org/mailman/listinfo/gcl-devel
>
>
>
>
--
Camm Maguire address@hidden
==========================================================================
"The earth is but one country, and mankind its citizens." -- Baha'u'llah