Re: How to embed Maxima in Common Lisp?



Thank you Robert for the detailed answer.

Finally I succeed to follow your instructions.
On my box Maxima was installed as debian package so it worked with GCL
only. When it came to this row:
:lisp (ext:saveinitmem "/tmp/foo-maxima.mem" :init-function 'cl-user::run),
GCL said "no such package "ext"".
I installed Maxima from source with clisp and now it worked as you
wrote.

Apropos web server, I tested "lisp-cgi-utils" and mod_lisp for Apache,
it's work.

Thanks again,
Yigal


On Aug 19, 8:40 pm, Robert Dodier <robert.dod...@xxxxxxxxx> wrote:

Yigal, I think a useful approach here is to create a Lisp
binary image which contains your function or functions to
run the web stuff plus all of Maxima. That is easy to do:
launch Maxima, load your Lisp and/or Maxima functions,
and save the current Lisp state. Then you can launch Clisp
and tell it to run the saved image. This method works
with other Lisp implementations as well.

e.g. Here is my replacement for CL-USER::RUN. You will want
to write a function to read and write a socket, I guess.

$ cat /tmp/foo-run.lisp
(defun cl-user::run ()
(in-package :maxima)
(format t "HELLO FROM REPLACEMENT CL-USER::RUN~%")
(let (($display2d nil))
(displa (mfuncall '$foo 123 '$abc)))
(bye))

Here is a Maxima function called from CL-USER::RUN.

$ cat /tmp/foo-function.mac
foo (x, y) := (x - y)^(y - x);

Now I'll create the saved image. I'm running an already-built
Maxima here; it is not necessary to rebuild Maxima to
incorporate your new functions. I'll tell Clisp to call my
replacement CL-USER::RUN.

$ maxima -q -l clisp
load ("/tmp/foo-function.mac");
load ("/tmp/foo-run.lisp");
:lisp (ext:saveinitmem "/tmp/foo-maxima.mem" :init-function 'cl-
user::run)
quit ();

Now I'll run Clisp with the saved image.

$ clisp -q -M /tmp/foo-maxima.mem
HELLO FROM REPLACEMENT CL-USER::RUN
(123-abc)^(abc-123)

By the way, if you are working with web servers or whatever,
there are Lisp libraries for that. But first you need to get
comfortable with Lisp + Maxima. Hope this helps, & good luck.

Robert Dodier


.



Relevant Pages

  • Re: Is Xlisp-Stat Dead?
    ... Well, I wonder if you have looked at Maxima, a computer algebra ... it is easy to drop into Lisp ... making a start on assembling quality numerics libraries. ... If/when you have some CL libraries to release, ...
    (comp.lang.lisp)
  • Re: How to embed Maxima in Common Lisp?
    ... If you have no money to spare, it is my feeling that there are better ... I'm learning Lisp (clisp) with purpose to build a site for interactive ... how can I call Maxima from within a Lisp program? ...
    (comp.lang.lisp)
  • How to embed Maxima in Common Lisp?
    ... I'm learning Lisp (clisp) with purpose to build a site for interactive ... solving school math problems. ... how can I call Maxima from within a Lisp program? ...
    (comp.lang.lisp)
  • Re: Errors when using Maxima code
    ... called "Sin" (it was published by Moses in 1967). ... Is the Lisp of Maxima different from the ANSI ... Common Lisp I use and how can I reconcile the differences? ...
    (comp.lang.lisp)
  • Re: performance and eloquence
    ... Maxima and Macsyma of which I both have and use have composed their entire ... user interface using basically a custom reader as far as I can tell. ... but then it wouldn't be lisp, ... I am not saying that maxima should not be a source of knowledge, ...
    (comp.lang.lisp)