streams, sockets and the command line



(Part of the motivation for this is in the companion message with the
subject `fresh-line'.)

I've been thinking about unifying Maxima's terminal- and socket-stream
based interfaces in terms of a new variable *top-io*, the standard
stream variables (sans *terminal-io*) being bound to synonym-streams
referring to it (in the case of an interactive session).  Maxima's
top-level input stream is then constructed as a concatenation of
string-streams corresponding to the various command line arguments and
of the value of *standard-input*.

The patch is at

http://members.inode.at/wjenkner/maxima/top-io.diff

I think this is the simplest way of achieving uniform behaviour with
respect to stream related issues across different lisps since it
reduces such problems to tweaking *top-io*.  For example, with CMUCL
or SBCL, loading the file

http://members.inode.at/wjenkner/maxima/tty-io.lisp

from the Maxima top-level or, e.g., maxima-init.lisp addresses the
`spurious newlines' issue, as discussed in the `fresh-line' message.

The patch tries to fix some other issues as well (this can also be
read as an essentially complete review of what in Maxima depends on a
specific standard streams setup like this one):

*) It gets rid of the socket-specific magic in CONTINUE.

*) The `-s' switch should now work correctly for all lisps; previously
it worked only if the value of *standard-input* happened to be a
synonym-stream of *terminal-io* (the value of which was a socket
stream, in this case).

*) On a related note, `appendfile' (that is, generating dribble files)
should now work under all circumstances (e.g., for CMUCL it didn't
work at all).  There are still glitches: With CLISP, CMUCL and SBCL, I
observed that apparently some newlines read during interactive queries
(like $asksign) are written in a delayed way to the dribble file.  GCL
seems to behave more or less in the same way as before.

*) I think `interactive' command line switches like `--run-string'
would make more sense if Maxima didn't exit after processing the
corresponding arguments.  Also, collecting Maxima commands would be
more useful than clobbering them (except for the value of batch-flag).
As an example for the greater flexibility of the proposed stream
set-up I have implemented such changes, but they are not essential.

Wolfgang