Previous: Tracing and Debugging Up: A Programmer's Guide for AKCL and MAXIMA Next: Porting Your Vaxima Package to Maxima
Converting Franz Lisp Programs to AKCL
There is an automatic translation tool
that takes Franz files file1.l etc. and produces the corresponding
CL files file1.lsp etc. Constructs that may not be translated automatically are flagged by the symbol franzlisp:: so you can spot them easily
to complete the translation manually.
Constructs to pay special attention:
- The franz zerop takes any s-expression and checks whether it
is zero. The CL zerop takes a number only.
- The CL arithmetic operator / when applied to two integers will
produce a fraction if the division is not exact. The Franz version would
truncate. Thus, the franz (/ i j) becomes the CL (floor (/ i j)).
- The fl2cl translator has a bug. It translates (- a)
(negative a) to (- a 0). Wonder what caused this bug.
But you should be aware of this.
- The fl2cl translator has another bug. It replaces
the franz fixp to test for a fixnum by the CL integerp
which is incorrect. The function fixnump in maxima can be used
instead. CL also defines most-positive-fixnum and most-negative-fixnum as quantities you can use/check.
- The franz lisp function = works with (= 'a 0)
but the CL = must be given only numerical args.
The translator fl2cl does not know about certain constructs that
exist under maxima which help make most existing Franz lisp packages port
easily to run under maxima.
Most Franz lisp files can be compiled successfully with little change
by the maxima compiler mc.
This is the difference between mc and the AKCL compiler lc.
The major difference between Franz and Common lisp are:
- CL does not distinguish between upper and lower case unless in
string constants.
- CL has multiple name spaces for identifiers called packages.
Commonly used packages include USER, LISP, MAXIMA,
SYSTEM. Generally, an indentifier var in one package is
not directly accessible from another package to avoid name conflicts.
If var is exported by a package, then it can be accessed with
the notation package-name:var.
If var has not been exported but you need to use it anyway,
then you must use the notation package-name::var.
- Opening files -- use open instead of outfile or
infile.
- CL arrays are established with make-array,
use zero based indexing for access (aref name i j),
and use (setf (aref name i j) value) to set value.
- The Franz construct (desetq (a (b c)) s-exp) is not used in CL.
To pre
- The CL break-loop processing is different and can be easily mastered
by looking at the display provided by the :H command at the break
loop.
- The Franz usages (defun fname nargs (...))
and (defun fexpr (args) ...) should be converted to
(defun fname (&rest args) ...).
- You may compile functions and files directly within CL with the
compile and compile-file commands.
- Compiled C code are handled differently by CL and is discussed
in a separate section here.
- To exit CL use (bye).