Would this (or something similar) also work for sbcl builds?

Martin

Am Samstag, 13. August 2016 13:08:54 UTC+2 schrieb Waldek Hebisch:
>
> Dima Pasechnik wrote: 
> > On Friday, August 12, 2016 at 6:36:31 PM UTC+1, Waldek Hebisch wrote: 
> > > - as Dima wrote Sage interface to Maxima works by putting Maxima 
> > >   in the same process as Sage.  This should be possible with 
> > >   FriCAS too.  I just checked that using Maxima build on to 
> > >   of sbcl and 'load-fricas.lisp' both FriCAS and Maxima seem 
> > >   to work in single process.  So it seems that small adjustment 
> > >   to build system should be enough 
> > > 
> > > as far as the latter is concerned, most of the needed code is already 
> in 
> > Sage; 
> > namely, src/sage/interfaces/maxima_lib.py is basically an example of 
> > running Maxima in ECL, 
> > which is embedded in Python; for the latter the code is in 
> > src/sage/libs/ecl.pyx 
> > 
> > In the latter one sees an example of calling CL functions from Sage: 
> > 
> >         sage: from sage.libs.ecl import * 
> >         sage: ecl_eval("(defun fibo (n)(cond((= n 0) 0)((= n 1) 1)(T (+ 
> > (fibo (- n 1)) (fibo (- n 2))))))") 
> >         <ECL: FIBO> 
> >         sage: ecl_eval("(mapcar 'fibo '(1 2 3 4 5 6 7))") 
> >         <ECL: (1 1 2 3 5 8 13)> 
> > 
> > That is, one would just need to adapt src/sage/interfaces/maxima_lib.py 
> to 
> > loading/running FriCAS instead. 
> > For this one needs to know some parts of FriCAS, that is, how to load it 
> in 
> > a running CL instance, etc etc... 
>
> With the following patch applied to FriCAS trunk: 
>
> ------------------<cut here>--------------------------- 
>
> Index: src/interp/util.lisp 
> =================================================================== 
> --- src/interp/util.lisp        (revision 2024) 
> +++ src/interp/util.lisp        (working copy) 
> @@ -392,6 +392,7 @@ 
>                    (push (list 'defparameter el (symbol-value el)) 
>                          initforms))) 
>            (push `(interpsys-ecl-image-init ,spad) initforms) 
> +          (push `(fricas-restart) initforms) 
>            (setf initforms (reverse initforms)) 
>            (push `progn initforms) 
>            (setf FRICAS-LISP::*fricas-initial-lisp-forms* initforms) 
> @@ -421,7 +422,7 @@ 
>             spad) 
>        (format *standard-output* "before fricas-restart~%") 
>        (force-output  *standard-output*) 
> -      (fricas-restart)) 
> +) 
>
>  (defun interpsys-image-init (parse-files comp-files browse-files 
>               asauto-files spad) 
>
> ------------------------<cut here>------------------ 
>
>
> I can use the following to produce fricas as shared library: 
>
> --------------<cut here>---------------------------- 
>
> ;;; load compiler 
> (defun foo () nil) 
> (compile 'foo) 
>
> (let ((*default-pathname-defaults* 
>        #P"//sklad/hebisch/fricas/axp7/ax-build87/src/interp/")) 
>      (load "../lisp/fricas-package.lisp") 
> ) 
> (let ((*default-pathname-defaults* 
>        #P"//sklad/hebisch/fricas/axp7/ax-build87/src/interp/")) 
>      (load "../lisp/fricas-config.lisp") 
>      (load "../lisp/fricas-lisp") 
>      (load "../lisp/primitives.lisp") 
>      (load "../lisp/fricas-ecl.lisp") 
>      (load "makeint.lisp") 
>      (let ((initforms (reverse FRICAS-LISP::*fricas-initial-lisp-forms*))) 
>           (setf initforms (reverse (cdr initforms))) 
>           (c:build-fasl "fricas_lib" 
>                    :lisp-files FRICAS-LISP::*fricas-initial-lisp-objects* 
>                    :ld-flags FRICAS-LISP::*fricas-extra-c-files* 
>                    :epilogue-code initforms) 
>        ) 
>  ) 
>
> --------------------<cut here>-------------------------- 
>
> This needs to be run once after FriCAS build.  It creates 
> "fricas_lib.fas" in  the 'src/interp' subdirectory of FriCAS 
> build tree. 
>
> Note: the paths above are from my machine.  Adjust to your 
> envirinment. 
>
> Once FriCAS shared library is created in ECL you can do: 
>
> (load "src/interp/fricas_lib.fas") 
> (in-package "BOOT") 
> (fricas-init) 
>
> and then use FriCAS functions.  Presumably in Sage it will look 
> like: 
>
> ecl_eval("(load \"src/interp/fricas_lib.fas\")") 
> ecl_eval("(in-package \"BOOT\")") 
> ecl_eval("(fricas-init)") 
>
> At some moment you need to set AXIOM environment variable 
> to inform FriCAS where it can find other files it needs. 
> In Sage it is probably most convenient to do from Python 
> code. 
>
> -- 
>                               Waldek Hebisch 
>

-- 
You received this message because you are subscribed to the Google Groups 
"FriCAS - computer algebra system" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/fricas-devel.
For more options, visit https://groups.google.com/d/optout.

Reply via email to