[Ecls-list] Latest changes

Juan Jose Garcia Ripoll lisp at arrakis.es
Mon Jul 4 02:54:07 UTC 2005


a major reorganization of the compiler is taking place. Roughly, the old 
{K,G,E}CL lisp-to-C translators were designed as three layers, called 
T1, T2 and T3, which do

(T1) Process each top-level form and translate it into some internal 
representation (C1FORMs).

(T2) Process the C1FORMs, removing unreachable code and finally 
producing C/C++ code for each form.

(T3) Similar to T2, but for each of the local/global functions which 
were created in each of the toplevel forms.

The major problem is that, as you see, everything is organized around 
the notion of toplevel form. For each of these, there is a processing 
function which compiles it. However, many of the lisp forms can appear 
both as toplevel and non-toplevel: for instance PROGN, SYMBOL-MACROLET, 
or even DEFUN. This leads to a horrible duplication of code and with 
time it has meant that the improvements for non-toplevel forms have not 
been propagated to the toplevel compiler.

Right now I am working on reorganizing/redesigning the compiler so that 
there is no notion of toplevel form, but just of lisp form. The idea is 
that in a near future you will be able to write code as follows

       ;; Process all forms into C1 intermediate representation
       (let* ((*compile-toplevel* 'T))
              (c1forms (mapcar #'lisp-to-c1form myforms)))
           ;; Finally output the code.
           (with-compiler-output (:c-file "foo.c" :h-file "foo.h")
             (mapc #'compile-c1form c1forms))))

Of course few people are going to use this, but the idea is that the 
compiler should have a very clear, very simple structure, where the fact 
that a form is toplevel is signified only by a global variable.

As of now, the code duplication in the T1 phase has been eliminated, and 
this has resulted in several fixes for the EVAL-WHEN forms. Furthermore, 
there is no longer need for special processing of DEFUN forms, and 
CLINES is implemented now as a very simple macro. There's still quite a 
lot to do, such as simplifying everything down to the LISP-TO-C1FORM and 
COMPILE-C1FORM interface, introducing new macrology, using the condition 
system for signalling errors/warnings, and unifying the environments for 
toplevel and nontoplevel forms.

Although I am conducting extensive testings before each minor commit, I 
expect some instability in CVS. If this is a concern, please stay with 
code before 3th July 2005.



More information about the ecl-devel mailing list