[Ecls-list] Is ECL really interpreted ?

Pascal J. Bourguignon pjb at informatimago.com
Mon Jul 16 11:02:23 UTC 2012


Matthew Mondor <mm_lists at pulsar-zone.net> writes:
> "Any function may be considered by an implementation to be a a compiled
> function if it contains no references to macros that must be expanded
> at run time, and it contains no unresolved references to load time
> values. See Section 3.2.2 (Compilation Semantics).
>
> Functions whose definitions appear lexically within a file that has
> been compiled with compile-file and then loaded with load are of type
> compiled-function. Functions produced by the compile function are of
> type compiled-function. Other functions might also be of type
> compiled-function."
>
> As I understand it, it is allowed for CL implementations to compile
> immediately, and ECL immediately compiles to bytecode, which can be
> interpreted.  As you know, the second level of compilation ECL supports
> is via C translation compiled with a C compiler, which is optional.
> But even in the first level bytecode compilation, all macros have
> previously been expanded, etc.
>
> I'm note sure, but CLisp seems to also do bytecode compilation
> immediately, but keeping functions under the type FUNCTION, with
> COMPILE being a noop that makes it of type COMPILED-FUNCTION.  In which
> case, it behaves like you expect in relation to COMPILED-FUNCTION-P.

clisp has a true interpreter, and it will macroexpand several times the
same macro.

clisp has a byte-code compiler, and a virtual machine.


On the other hand,  ECL indeed byte-compiles the functions
automatically.

> (require :cmp)
:cmp
> (defun f (x) (if (zerop x) 1 (* x (f (1- x)))))

F
> (function f)

#<bytecompiled-function F>
> (compile 'f)

;;; Loading #P"/data/languages/ecl/lib/ecl-12.2.1/cmp.fas"
;;; OPTIMIZE levels: Safety=2, Space=0, Speed=3, Debug=0
;;;
;;; End of Pass 1.
F
NIL
NIL
> (function f)

#<compiled-function F>

-- 
__Pascal Bourguignon__                     http://www.informatimago.com/
A bad day in () is better than a good day in {}.




More information about the ecl-devel mailing list