Python syntax in Lisp and Scheme

Paul F. Dietz dietz at dls.net
Fri Oct 10 07:35:28 EDT 2003


Andrew Dalke wrote:
> Pascal Costanza:
> 
>>Furthermore note that this is not an implementation difference. The ANSI
>>standard defines the function COMPILE.
> 
> 
> Is the implementation free to *not* compile the code when the
> COMPILE function is called?  That is, to leave it as is?  How
> would a user tell the difference without running a timing test?

In CL, COMPILE (and COMPILE-FILE) are not required by the CL spec
to convert lisp code to machine language.  Many implementations do,
however, and it tends to be one of the major defining characteristics
of a CL implementation.

A conforming implementation must perform certain minimal steps
at compilation time.  See section 3.2.2.2 of the CL spec.  It states:

    Minimal compilation is defined as follows:

     * All compiler macro calls appearing in the source code being
       compiled are expanded, if at all, at compile time; they will
       not be expanded at run time.

     * All macro and symbol macro calls appearing in the source code
       being compiled are expanded at compile time in such a way that
       they will not be expanded again at run time. macrolet and
       symbol-macrolet are effectively replaced by forms corresponding
       to their bodies in which calls to macros are replaced by their expansions.

     * The first argument in a load-time-value form in source code
       processed by compile is evaluated at compile time; in source code
       processed by compile-file, the compiler arranges for it to be
       evaluated at load time. In either case, the result of the evaluation
       is remembered and used later as the value of the load-time-value
       form at execution time.

Other than this,a conforming implementation is allowed to leave the
source code alone, compile it to byte codes, compile it to machine
language, or any other correctness-preserving transformation.

It would be conforming to do the minimal compilation, produce byte codes, then
dynamically convert the byte codes to machine language at run time as in Psyco.

	Paul





More information about the Python-list mailing list