Menu

#4567 gnuplot gives obscure Lisp error when gnuplot_command is not a string

None
closed
gnuplot (27)
5
2025-06-22
2025-06-14
No

Dear all,
When one outputs a variable, there is no 'type' printed - is there a (native) function to query the type? Yes, e.g numberp(), for numbers, but in general?

E.g. I query gnuplot_command, then I set it to the same value:

(%i1) gnuplot_command;
(%o1)                               gnuplot
(%i2) gnuplot_command:gnuplot;
(%o2)                               gnuplot
(%i3) plot2d(x,[x,1,2]);

Maxima encountered a Lisp error:

 The value
   $GNUPLOT
 is not of type
   (OR STRING PATHNAME SYNONYM-STREAM FILE-STREAM)
 when binding PATHNAME

Automatically continuing.
To enable the Lisp debugger set *debugger-hook* to nil.

That did not work, the variable is now of type symbol, not longer a string. But if I output the variable, I get not idea, if it is a string or symbol. It must be set enclosed in quotation marks, then it works.

(%i4) gnuplot_command:"gnuplot";
(%o4)                               gnuplot
(%i5) plot2d(x,[x,1,2]); /* works ok */

Is there any (native) function or output (typeof() or something else?) where one can get an idea, whats wrong?
Because the OUTPUT of gnuplot_command is the same in both cases. (Maybe it should be "gnuplot" in the string case)?

I found :lisp (type-of $a) but there is no Maxima equivalent?
Best regards, Wolfgang

Discussion

  • Stavros Macrakis

    • labels: --> gnuplot
    • summary: Type of a variable? --> gnuplot gives obscure Lisp error when gnuplot_command is not a string
     
  • Stavros Macrakis

    The error you're getting is not about the variable gnuplot, but about the value of gnuplot_command. Neither Maxima nor Lisp supports the notion of a variable type.

    The bug here is that Maxima is giving an obscure internal Lisp error, rather than a meaningful Maxima error. Since it is a Lisp error, it doesn't look at stringdisp when displaying the value.

    A reasonable Maxima error message would be something like: "gnuplot_command is 'gnuplot', which is not a valid pathname string" or something.

     
  • Robert Dodier

    Robert Dodier - 2025-06-14

    Couple of things here. (1) plot2d/plot3d should try harder to get a string -- probably just call $string (via mfuncall since it's a Maxima defmspec) from the value of gnuplot_command.

    (2) plot2d/plot3d should, of course, catch any Lisp errors and create a Maxima error instead.

     
    • Stavros Macrakis

      I disagree that we should call $string on its arguments.
      At most, accept either a string or a symbol.

      Behavior like this helps no one (and should be fixed in load, too):

      load(a*b);
      
      Maxima encountered a Lisp error:
      
      In function STRING, the value of the first argument is
      ((MTIMES SIMP (0 "stdin" SRC)) $A $B)
      which is not of the expected type STRING
      

      Tested in
      Maxima on Android 3.2.1 September 7, 2018
      Maxima 5.41.0 http://maxima.sourceforge.net
      using Lisp ECL 16.1.3

       
      • Raymond Toy

        Raymond Toy - 2025-06-15

        5.41 is really old, isn't it? With current(ish) HEAD, I get:
        (%i8) load(a*b); load: argument must be a string, symbol, or pathname; found: a b -- an error. To debug this try: debugmode(true);
        Hmm. How do you get a Lisp pathname in Maxima? Curiously $load does actually check if the arg is pathnamep.

         
        • Stavros Macrakis

          Agreed that 5.41 is carbon dated (from 2018!), but it's the latest version of Maxima On Android as far as I can tell.

          Does anyone know how to build Maxima on Android with a more recent version?

           
          • Jaime E. Villate

            On 17/06/25 07:22, Stavros Macrakis wrote:

            Agreed that 5.41 is carbon dated (from 2018!)

            More precisely, the release date of 5.41.0 was 2017-10-03.

            Jaime

             
            • Stavros Macrakis

              I was misled by the startup banner, which reads

              Maxima on Android 3.2.1 September 7, 2018
              Maxima 5.41.0 http://maxima.sourceforge.net
              

              I guess September 7, 2018 is the build date of MaximaOnAndroid.

              Which brings up back to the original question: does anyone know how to build MoA from Maxima source?

               
              • Raymond Toy

                Raymond Toy - 2025-06-17

                I don't know how to build it, but this appears to be the repo for it: https://github.com/YasuakiHonda/Maxima-on-Android-AS

                I would certainly like an update as well. Even though I rarely use it, it comes in very handy sometimes!

                 
  • Raymond Toy

    Raymond Toy - 2025-06-14

    Having stringdisp set to true makes the output from gnuplot_command clearer that a string is expected.

    We could also change the definition of $gnuplot_command from a defvar to a defmvar and use the :setting-predicate option to make sure it only accepts a string.

    If we do this, we should also do the same for other user-visible variables like $mgnuplot_command, $geomview_command, $xmaxima_plot_command at the very least. I see there are other user-variables that should probably be a string.

     
    • Raymond Toy

      Raymond Toy - 2025-06-17

      Unless there are objections, I'm going to make $gnuploat_command and related variables only accept strings. Everything else will produce a Maxima error.

       
  • Raymond Toy

    Raymond Toy - 2025-06-21
    • status: open --> closed
    • assigned_to: Raymond Toy
     
  • Raymond Toy

    Raymond Toy - 2025-06-21

    Fixed by commit [c2af73] which forces $gnuplot_command t o be a string.

     

    Related

    Commit: [c2af73]

  • Wolfgang Dautermann

    Thank you!

     

Log in to post a comment.