[PATCH] 'fricas_has_remove_directory', again

6 views
Skip to first unread message

Qian Yun

unread,
Jan 3, 2024, 6:07:51 AM1/3/24
to fricas-devel
I suggest to check for symbol instead of "#+" feature testing.

This will allow FFI-free pure-lisp build.

To quote the FriCAS development goals:

"make it easier for external programs to interface with FriCAS"

I think that FFI-free pure-lisp build is one step toward this goal.

fricas0 is one example that utilizes pure-lisp build.

In Sagemath, there's a pexpect (IO) based interface for FriCAS and
Maxima, but there's an additional ECL based interface for Maxima.
So using FriCAS as a pure-lisp library can have its advantages.

- Qian


diff --git a/src/interp/nlib.lisp b/src/interp/nlib.lisp
index 8c844fa7..ffdacae6 100644
--- a/src/interp/nlib.lisp
+++ b/src/interp/nlib.lisp
@@ -304,10 +304,10 @@
;; ($ERASE filearg) -> 0 if succeeds else 1
(defun |erase_lib|(filearg)
(if (|fricas_probe_file| filearg)
- #+:fricas_has_remove_directory
- (|remove_directory| filearg)
- #-:fricas_has_remove_directory
- (delete-directory filearg)
+ (let ((sym (find-symbol "remove_directory" "FRICAS-LISP")))
+ (if sym
+ (funcall sym filearg)
+ (delete-directory filearg)))
1))

(defun |erase_lib0|(fn ft) (|erase_lib| (|make_filename0| fn ft)))

Dima Pasechnik

unread,
Jan 3, 2024, 6:27:21 AM1/3/24
to fricas...@googlegroups.com
I don't see why an embedded ECL-based FriCAS must be pure lisp. ECL has its FFI just fine.

In fact, one might consider developing a plain C library allowing calling FriCAS via libecl.so

Waldek Hebisch

unread,
Jan 3, 2024, 7:42:26 AM1/3/24
to fricas...@googlegroups.com
On Wed, Jan 03, 2024 at 07:07:47PM +0800, Qian Yun wrote:
> I suggest to check for symbol instead of "#+" feature testing.
>
> This will allow FFI-free pure-lisp build.

IMO pure-lisp build is futile. We want to use GMP, blas, lapack
and possibly our own routines. Currently ECL and GCL use
GMP for bignums, so that covers important part. But we also
would like to use GMP for polynomial multiplication and for
that purpose bypassing Lisp bignums is very desirable. Currently
we have proof-of-concept lapack and blas interface. Main issue
blocking its inclusion is configure machinery to detect blas
and lapack, FFI part is easy to resolve.

> To quote the FriCAS development goals:
>
> "make it easier for external programs to interface with FriCAS"
>
> I think that FFI-free pure-lisp build is one step toward this goal.
>
> fricas0 is one example that utilizes pure-lisp build.
>
> In Sagemath, there's a pexpect (IO) based interface for FriCAS and
> Maxima, but there's an additional ECL based interface for Maxima.
> So using FriCAS as a pure-lisp library can have its advantages.

Big point about ECL is ease of calling C code. And it seems that
to get good performance using ECL we need to call C: "native"
ECL is too slow. So really library use should include FFI.

--
Waldek Hebisch

Dima Pasechnik

unread,
Jan 3, 2024, 5:08:11 PM1/3/24
to fricas...@googlegroups.com


On 3 January 2024 12:42:23 WET, Waldek Hebisch <de...@fricas.org> wrote:
>On Wed, Jan 03, 2024 at 07:07:47PM +0800, Qian Yun wrote:
>> I suggest to check for symbol instead of "#+" feature testing.
>>
>> This will allow FFI-free pure-lisp build.
>
>IMO pure-lisp build is futile. We want to use GMP, blas, lapack
>and possibly our own routines. Currently ECL and GCL use
>GMP for bignums, so that covers important part. But we also
>would like to use GMP for polynomial multiplication and for
>that purpose bypassing Lisp bignums is very desirable. Currently
>we have proof-of-concept lapack and blas interface. Main issue
>blocking its inclusion is configure machinery to detect blas
>and lapack,

you may want to use what we have in SageMath for
blas/lapack detection.

We actually only use OpenBLAS (which is the most
popular optimised open-source BLAS/LAPACK implementation, available on almost all Linux, macOS, and *BSDs)

It's very easy if pkg-config for OpenBLAS is available.
(we do some tricky things to generate pkg-config files if they are not there, but perhaps you may just skip this, and assume it's available)
Reply all
Reply to author
Forward
0 new messages