Rupert Swarbrick | 1 Jul 23:45 2013

Tracing functions (and bug 2595)

In bug 2595[1], the reporter points out that $TRACE doesn't work very
well on functions with quoted arguments. A simpler example than the
original report is the following:

    (%i39) fun ('var) := var;
    (%o39)                         fun('var) := var
    (%i40) x: 1$

    (%i41) fun(x);
    (%o41)                                 x
    (%i42) trace(fun)$

    (%i43) fun(x);
    1 Enter fun [1]
    1 Exit  fun 1
    (%o43)                                 1
    (%i44) untrace(fun);
    (%o44)                               [fun]

The problem is that the way $TRACE is implemented completely ignores the
possibility that the original function was defined with one or more
quoted arguments. I don't know the history here: was trace written
before the introduction of the "fun('var) := ..." syntax?

Anyway, I was wondering if any more senior developers had a good idea of
how to make this work correctly. A rather hacky solution that occurred
to me was to use something like the MFEXPR* case in the enormous MEVAL1
cond and make the stub function that calls the trace code also deal with
expanding (some of) its arguments. But that's pretty horrible. Anyone
got a better idea?


Maxima mailing list
Maxima <at>