Menu

#4698 alt-display breaks trace's output

None
closed
5
3 days ago
5 days ago
Leo Butler
No

alt-display does not play nicely with trace. The following output shows what happens when set_alt_display is used to replace the default 2d printer (an o in the output of trace represents a space).

$ maxima
Maxima branch_5_49_base_141_gd7e37bb4c https://maxima.sourceforge.io
using Lisp SBCL 2.6.0.debian
Distributed under the GNU Public License. See the file COPYING.
Dedicated to the memory of William Schelter.
The function bug_report() provides bug reporting information.
(%i1) load("alt-display.mac");
(%o1) /usr/local/share/maxima/branch_5_49_base_141_gd7e37bb4c/share/contrib/al\
t-display/alt-display.mac
(%i2) set_alt_display(2,tex_display);
\mbox{\tt\red({\it \%o}_{2}) \black}$$\mathbf{done}$$
(%i3) f(x):=if x=1 then 1 else x*f(x-1);
\mbox{\tt\red({\it \%o}_{3}) \black}
\begin{verbatim}
f\left(x\right):=\mathbf{if}\;x=1\;\mathbf{then}\;1\;\mathbf{else}\;x\,f\left(x-1\right);
\end{verbatim}
(%i4) trace(f);
\mbox{\tt\red({\it \%o}_{4}) \black}$$\left[ f \right] $$
(%i5) f(5);
o

oo

ooo

oooo

oooo

ooo

oo

o


\mbox{\tt\red({\it \%o}_{5}) \black}$$120$$

What is happening is that tex_display, in common with the other display functions defined using define_alt_display, checks if its input is a text form. If it is, alt_display_text is used to print the text form. Except, it assumes that the form looks like

((MTEXT . JUNK) "text to be printed")

Alas, trace's text forms look like

((MTEXT . JUNK) ((SPACEOUT N) ...)

The solution is to change alt_display_text to use the default printer, DISPLA, of these forms.
This is what the attached patch does.

1 Attachments

Discussion

  • Leo Butler

    Leo Butler - 5 days ago

    The attached patch also works, too.

     
  • Leo Butler

    Leo Butler - 3 days ago

    This is fixed in commit a0348f57.

     
  • Leo Butler

    Leo Butler - 3 days ago

    With the patch:

    maxima-local
    Maxima branch_5_49_base_188_g2bd018694 https://maxima.sourceforge.io
    using Lisp SBCL 2.6.0.debian
    Distributed under the GNU Public License. See the file COPYING.
    Dedicated to the memory of William Schelter.
    The function bug_report() provides bug reporting information.
    (%i1) load("alt-display.mac");
    (%o1) /home/x201-work/work/maxima/sandbox/git/maxima-code/share/contrib/alt-di\splay/alt-display.mac
    (%i2) ff(n) := if n=1 then 1 else n*ff(n-1) $
    (%i3) trace(ff) $
    (%i4) alt_display_text_prefix:"<mtext>" $
    (%i5) alt_display_text_suffix:"</mtext>" $
    (%i6) set_alt_display(2,tex_display);
    \mbox{\tt\red({\it \%o}_{6}) \black}$$\mathbf{done}$$
    (%i7) ff(5);
    <mtext>1 Call   ff [5]</mtext>
    <mtext> 2 Call   ff [4]</mtext>
    <mtext>  3 Call   ff [3]</mtext>
    <mtext>   4 Call   ff [2]</mtext>
    <mtext>    5 Call   ff [1]</mtext>
    <mtext>    5 Return ff 1</mtext>
    <mtext>   4 Return ff 2</mtext>
    <mtext>  3 Return ff 6</mtext>
    <mtext> 2 Return ff 24</mtext>
    <mtext>1 Return ff 120</mtext>
    \mbox{\tt\red({\it \%o}_{7}) \black}$$120$$
    
     
  • Leo Butler

    Leo Butler - 3 days ago
    • status: open --> closed
     

Log in to post a comment.

MongoDB Logo MongoDB