[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
passing a file pointer from T to C (under UNIX)
- To: srt@UCLA-LOCUS
- Subject: passing a file pointer from T to C (under UNIX)
- From: Jonathan A Rees <JAR@MIT-MC>
- Date: Mon ,25 Feb 85 13:50:00 EDT
- Cc: t-users@YALE.ARPA
- In-reply-to: Msg of Fri 22 Feb 85 16:03:01 PST from Scott Turner <srt at UCLA-LOCUS>
Date: Fri, 22 Feb 85 16:03:01 PST
From: Scott Turner <srt at UCLA-LOCUS>
I note with sadness that the "stream" that WITH-OUTPUT-TO-STRING creates
cannot be passed outside of T. I wanted to be able to do this in order to
snarf up the output of a system function (in this case, ls) and then do
some further processing on it.
Undoubtedly this could be done by redirecting the output of the system
program to a file and then reading the file, but out of curiousity, is
there any easier way?
I am flatterred; you certainly expect a lot from the implementation. I
know of no LISP that is capable of anything like this. It would indeed
be nice if there were a general coercion from streams to Unix and Aegis
file descriptors and the equivalent on VMS, but that would be a lot of
code for the implementors to write, and its utility would be marginal
compared with that of other things the implementors might spend their
Try looking at the T sources and ask yourself this question: what would
a STREAM-CHANNEL method for the stream returned by
MAKE-OUTPUT-STRING-STREAM actually do?
It could open a temporary file, which would be read and
deleted by the CLOSE method. It would have to tell the WRITEC, WRITES,
etc. methods to write to the file instead of the internal buffer.
... Sure, it would be a good hack (I'm not convinced it would work in
general; there might be locking problems on other operating systems).
Maybe it'll get done some day. But why stop there? You'd want
STREAM-CHANNEL or whatever to work on ANY output stream, and that's much
harder. You'd now need to set up a separate process to receive output
and funnel it back to T. Maybe that would be possible in a "concurrent
T", but it certainly isn't in T2.
So the answer to "is there an easier way" is: it is always easier for
you if someone else does your work for you, and easier for the
implementors if they can get someone else to do their work for them.