Maxima's REPL



Am Freitag, den 08.04.2011, 12:06 -0700 schrieb Richard Fateman:

> I don't know what displayinput does, but just guessing, I would think it 
> has to do with whether you are doing a batch() input from a file or from 
> a keyboard.  If the input is from a file, do you want to display the 
> input as well as the output?
> Or just quietly chew up the input.  And for the web interface, I'm not 
> sure what you would want to do.  You could, perhaps with some benefit, 
> display the input nicely.  You could display balanced parens and 
> "pretty-print" the command; this might even lead some people to notice 
> bugs in their input.  It certainly does the job for me when I write 
> programs in lisp.


The keywords DISPLAYINPUT and NODISPLAYINPUT are the headers of the
operators ; and $. The parser - that is the function MREAD - puts these
keywords as first operators into the input expression, e.g.

(%i3) a+b;
  0: (MREAD #<SYNONYM-STREAM :SYMBOL SB-SYS:*STDIN* {9130451}> (NIL))
  0: MREAD returned ((DISPLAYINPUT) NIL ((MPLUS) $A $B))

(%i4) a+b$
  0: (MREAD #<SYNONYM-STREAM :SYMBOL SB-SYS:*STDIN* {9130451}> (NIL))
  0: MREAD returned ((NODISPLAYINPUT) NIL ((MPLUS) $A $B))

The main loop CONTINUE calls MREAD to get the input expression R. The
display routines check the keywords DISPLAYINPUT and NODISPLAYINPUT to
control the output. In the routine CONTINUE the value of (CADDR R) is
assigned to the variable $__. Therefore $__ holds the last input without
the keywords DISPLAYINPUT and NODISPLAYINPUT.

Dieter Kaiser