On Mon, Sep 19, 2022 at 10:24:00PM +0800, Qian Yun wrote:
> I'd like to add new lisp support for FriCAS soon, starting with ABCL.
>
> First, ABCL almost supports fricas0, I have identified 2 bugs and they
> are fixed upstream (not merged yet, should be available next release).
> So I think it is time to add ABCL support in FriCAS repo.
>
>
https://github.com/armedbear/abcl/issues/500
>
https://github.com/armedbear/abcl/issues/504
>
> Second, to add ABCL support for FriCAS, I guess it is similar to add
> support for POPLOG? So basically adding "#+abcl" near "#+poplog".
Well, adding "#+abcl" in appropriate places (which may be similar
to #+poplog).
> Third, if so, I'd like to clean it up a bit before adding ABCL support:
> how about grouping those implementation specific stuff into a single
> place/file?
I am not sure what you mean. Let me say a bit about logic that
I use when I place Lisp code somewhere. First, lisp/primitives.lisp
is for use from code generared by Spad compiler. In ideal world
rest of Lisp code would be in lisp/fricas-lisp.lisp. However,
for GCL package construction must be in separate file, so we
get lisp/fricas-package.lisp. GMP support is specific to sbcl
and Clozure CL, it is simpler and more logical to keep in separate
file than to use conditionals. That explains layout of src/lisp
subdirectory. There are also Lisp files in src/interp. Those
I consider legacy files and hope that some day they most of
them will go away. foam_l.lisp is Aldor specific (needed to
interface with Aldor). interp-proclaims.lisp is really only present
because it could be used to optimize calls when building FriCAS
on top of GCL. IIUC with newer GCL this is no longer needed or
useful. So the only useful thing done by interp-proclaims.lisp
is to set GCL compilation options (we were not able to use
default GCL setting as in such case build failed).
vmlisp.lisp contains mostly compatibility code with old
IBM Lisp dialect. Use of several constructs there should
be removed (replaced by simpler code), so some parts will
be deleted. Some code in other files really does not need
to be in Lisp, some is candiate for replacement by alternative
code. I keep it where it is mostly to make history clearer
(history helps when I want to reverse-engineer why code
was written in given way).
There are also build details: Boot translator depends on
src/lisp but I belive that it is independent from src/interp.
Now, concerning implementation support. There are some
implementation-specific functions that we need, they are
mostly in fricas-lisp.lisp. Having them together in single
file helps, as we can share parts between similar implementation.
Also, parts of fricas-lisp.lisp are common to all implementations,
keeping this together make it easier to understand the code.
Conditional code in other files is really imperfection of
the world: we need conditionals in primitives.lisp to get
better performance. And there are irregularities in other
places, moving affected code to src/lisp would split logic
making it harder to understand. Moving all Lisp code to src/lisp
would IMO move too much code.
BTW: In our code we have 3 subtly different "general-purpose"
Lisp sorting functions. IMO we should really have typed
data and use type-specific sort functions, so it would be
good to replace or remove them. To put it differenty: all
uses of those are potential bugs. We should look at the
uses, discover what is sorted and decide if sorting is
needed at all. And if sorting is needed we should
decide which _specific_ function to call. To explain
more, those function handle/handled some things that
FriCAS never uses and to do this had dependency on
obscure implementation details. Most problematic part
is now removed but I think that this code could be
cleaned up much more and made much simpler.
--
Waldek Hebisch