Maxima Manual. Node: LISP-AND-MACSYMA



All of Maxima is of course written in lisp. There is a naming convention for functions and variables: All symbols which begin with a "$" sign at lisp level, are read with the "$" sign stripped off at Macsyma level. For example, there are two lisp functions TRANSLATE and $TRANSLATE. If at macsyma level you enter TRANSLATE(FOO); the function which is called is the $translate function. To access the other function you must prefix with a "?":


Of course, this may well not do what you wanted it to do since it is a completely different function.

To enter lisp level on the lisp machine, you should type Suspend or Control-Suspend. This will cause a lisp break loop to be entered. You could now evaluate $d2 (or macsyma:$d2 if you have not done (pkg-goto 'macsyma)) and view the value of the line label D2, in its internal lisp format. Resume or abort will return to Macsyma top level.

Thus if you intend to write lisp functions to be called at macsyma level you should name them by names beginning with a "$".

If you are at lisp level and wish to read a macsyma expression you may enter

			  (setq $foo #$[x,y]$)

This will have the same effect as entering


except that foo will not appear in the VALUES list. In order to view foo in macsyma printed format you may type

(displa $foo)

In this documentation when we wish to refer to a macsyma symbol we shall generally omit the $ just as you would when typing at macsyma level. This will cause confusion when we also wish to refer to a lisp symbol. In this case we shall usually try to use lower case for the lisp symbol and upper case for the macsyma symbol. For example LIST for $list and list for the lisp symbol whose printname is "list".

To enter more complicated lisp expressions at macsyma level you may need the quoting character \ eg. for the lisp function make-array


would be have the same result as the lisp form

(setq $aa (make-array 3  :fill-pointer 0)).

Since functions defined using the MAXIMA language are not ordinary lisp functions, you must use mfuncall to call them. For example:

(D2) 			    FOO(X, Y) := X + Y + 3

then at lisp level

CL-MAXIMA>>(mfuncall '$foo 4 5)

A number of lisp functions are shadowed in the maxima package. This is because their use within maxima is not compatible with the definition as a system function. For example typep behaves differently common lisp than it did in Maclisp. If you want to refer to the zeta lisp typep while in the maxima package you should use global:typep (or cl:typep for common lisp). Thus

  (macsyma:typep '(1 2)) ==> 'list
  (lisp:typep '(1 2))==> error (lisp:type-of '(1 2))==> 'cons

To see which symbols are shadowed look in "Maxima-source:maxima;sysdef.lisp" or do a describe of the package.