[Ecls-list] Is ECL really interpreted ?

Matthew Mondor mm_lists at pulsar-zone.net
Mon Jul 16 02:45:30 UTC 2012


On Sun, 15 Jul 2012 22:41:35 +0200 (CEST)
ecky at ecky.fr wrote:

> Hello,
> 
> I'm currently evaluating the possibility to use ECL for my software-project and it is important for me that the language I use is interpreted with optional partial compilation on demande (for optimisation reasons). I wonder if ECL has this capacity, because i tested (after having installed ECL) the following code snippet (from the book "Object-Oriented Common Lisp") and I'm getting unexpected results:
> 
> (defun test1 (n)
>   (do ((i 0 (+ i 1)))
>       ((> i n) i)
>       (+ i 1)))
> 
> (functionp #'test1)
> T
> 
> (compiled-function-p #'test1)
> T
> 
> It's the last T that surprises me, should be NIL!? Only if you issue the command (compile 'test1) it should get compiled ...

"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.

> Next question would be, how can I dynamically load à shared library (or any other) manually by the program in order to access the functions it contains (the program will know itself which library to load and when ...).

If ECL was built with dffi support (and linked against libffi),
*FEATURES* should contain :DFFI, and it should support dynamically
loading libraries at runtime.  Please look at:

FFI:FIND-FOREIGN-LIBRARY  Function
FFI:LOAD-FOREIGN-LIBRARY  Macro

(http://ecls.sourceforge.net/new-manual/rn06.html)
-- 
Matt




More information about the ecl-devel mailing list