[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

standard stream redirection



  Does anybody know a way (if posssible a simple way) to redirect the
output of the trace to a file? According to the Common Lisp refrence
maunal, it is sufficient to open an output file and to rebind the
variable *trace-output* to the open file. The problem is that is
does not work on Symbolics.

We wrote the following code:

(let ((name ":>eb>rep.text"))
  (with-open-file (file (pathname name)
                        :element-type 'string-char
                        :direction :output
                        :if-exists :new-version
                        :if-does-not-exist :create)
    (print *trace-output*)
    (terpri)
    (print (streamp *trace-output*))
    (terpri)
    (let ((*trace-output* file))
      (declare (special *trace-output*))
      (print *trace-output*)
      (terpri)
      (print (streamp *trace-output*))
      (terpri)
      (algebra-value '(+ x x)))))

  As far as i know, that code is a pure Common Lisp piece of code.
I tried it on an APPOLO with The Lucid Common Lisp, and it worked
perfecly. On a symbolics, it does not work at all. First of all, successive
evaluations of that piece of code does not create new versions of the file.
Second, when a traced function is called (for example: algebra-value), i got
an error message indicating that the stream corresponding to the open file
is unable to handle the message :character-width. I guess that the message
is sent by the trace. In addition i did not find any piece of documentation
indicating the precise nature of strams involved in trace, neither any way
to redirect of one the standard stream like *trace-output*.

  This seems not only an undocumented incompatibility with the Common Lisp
standard, but it is really annoying, because we really need it.

  The only way to "solve" the problem we found is to use the entryprint and
exitprint option of the trace facility. But that solution is clearly
annoying if you must trace a lot of functions on a file. In addition you lose
the indentation.

(with-open-file (file "try.text"
                        :element-type 'string-char
                        :direction :output
                        :if-exists :new-version
                        :if-does-not-exist :create)
    (declare (special file))
    (trace (facto :entryprint (format file "~% ENTER ~S with: ~S"
                                      'facto
                                      arglist)
                  :exitprint  (format file "~% EXIT ~S with: ~S"
                                      'facto
                                      values)))
    (facto 6))

Does anybody have a solution (or a least a beginning of solution) to
that problem ?

  Emmanuel Baechler
  Artificial Intelligence Laboratory
  Computer Science Department
  Swiss Federal Institute of Technology at Lausanne
  e-mail: baechler%clsepf51.bitnet@cunyvm.cuny.edu