Skip to content
Prev 7603 / 63424 Next

a version of source() which keeps comments ?

Martin Maechler <maechler@stat.math.ethz.ch> writes:
Historically, this is what source() should have done all the time if
it were to be in keeping with other Unix programs (shift input from
stdin temporarily). The source() that we have is really "evaluate
file". I don't think we can source() an infinite stream like a pipe or
a socket, can we?

Actually, I think it can be done with a little careful file descriptor
switching. (Turn of readline processing, etc., switch stdin to file,
run till eof or error, switch back and reestablish readline.) We'd
still have the reparse-on-incomplete thing, since that also happens on
stdin -- something I suspect isn't necessary, but it takes a fairly
hard look at the grammar itself to find out. 

(This kind of stuff has long been on my might-do list of projects,
along with (re)fixing the comment issue and providing better
information on parse/eval errors. I'd better not feel possessive about
the ideas...)