tex, imaxima, lisp objects



On 09/23/2013 01:12 AM, Richard Fateman wrote:
>  OK, I looked at this some more. This does not seem to be only a tex() 
error, but a
>  design disagreement
>  about how to format the result of make_array.
>

I agree that there should be design decisions and some unification.
The hack I made is probably a reasonable stop-gap. I can send a diff.

Currently, there are different decisions (or just allowing errors) by
the various interfaces. Here is a brief summary.

WXMAXIMA

wmaxima uses its own `wxxml' output, it is based on the
tex code by RJF. But it is separate, and does not depend
on, or necessarily respect, formatting decisions in maxima
for display2d:true or tex().

It checks the type of a few less common objects and does something to
format them.  Here what wxmaxima does with display2d:true for a few
objects (not exhaustive list)

  1) For lisp arrays, it just prints the dimension.
     In some cases at least, one could convert the array to
     a list and make a mark to show it is an array or something.
     But this is not implemented.
  2) For a lisp hash it just prints that it is a hash table.
  3) If (type-of x) is in (GRAPH DIGRAPH), it formats with ~a which uses
     the print-function of the GRAPH structure.
  4) For any other lisp structure, it just prints Lisp Structure
     and the name of the structure. It could use format with
     ~a, but depending on the structure, it might look weird.

   Is there a way to query whether the structure has a print
   function ?  I have a structure call AEX, which has a print function.
   I change the wxmaxima code to call the print-function if
   type-of is (GRAPH DIGRAPH AEX), which then prints the AEX as
   it should be. (This is also what command-line maxima does with
   display2d:true.) Maybe wxmaxima could check if there is
   a print function for any structure encountered.

My modification to the tex code does not work with wxmaxima,
because it uses modified tex code with new names for everything.

----

For display2d:false, wxmaxima just does what command-line
maxima does, and does not use the modified texifying code:

  1) The graph comes out a bit weird, because of escapes.

  2) The array:
     {Lisp Array: #(0 0)}

  3) I modified code in grind.lisp so that AEX structures
     are printed in a way that can be read again by maxima. So this
     works pretty well. (except that it is broken in some cases. Someday,
     I'll try to fix it or get some help.)

------------------------------------------------------
IMAXIMA

imaxima uses display2d true and false just as command line.  It
respects a third option display2d:imaxima, which uses again a
hacked/modified version of the tex code, but this time relying on much
of the original tex code in mactex.  It does not trap unhandled cases,
as does wxmaxima, but rather prints the same error that command line
maxima does when calling tex().

In order to fix this for imaxima, I have to change both the original
tex code and a function in imaxima. This calls sconcat on the object
and then wraps the result in a tex verbatim construction.

---------------------------------------------------------
COMMAND LINE MAXIMA

The tex function cannot handle some things. As mentioned above, I
modified tex-atom to try to trap as much as possible and just wrap it
in tex verbatim. This is just one line. Not always optimal formatting,
but sometimes good (if as is the case with AEX, there is a print
function), and always better than a lisp error, and the
all-to-frequent invitation to enter the lisp debugger.

If display2d is false, the code in grind.lisp calls functions
in ar.lisp to do something simple with arrays,
i.e. "{Lisp Array ...}"

---------------------------------------------------------
TEXMACS

I don't completely understand what it does.  If display2d:true, then it
apparently tries to use tex(), which fails with an error in the usual
cases. My hack to tex-atom does work, however, and arrays, graphs,
etc. are printed. It does use some kind of trapping, though, because
the AEX structures are formatted using the maxima non-2d formatting
code even if display2d is true. But, it looks a bit different. It is
also interesting that, while imaxima creates and embeds postscript
images if display2d:true, wxmaxima somehow displays the tex output in
a way that individual characters can still be selected and copied.