On Mar 29, 2009, at 10:24 AM, Michele Simionato wrote:
BTW, I have another question, is the Ikarus compiler
smart enough to find errors like this one even in
internal definitions.
In principle definitions of the kind
(define x <some expression depening only on names known
at compile time>)
could be evaluated at compile time everywhere in the
program, not only at top level.
If you have:
(define x 5)
(define y (+ x 1))
(define z (* x y))
then the ikarus optimizer will copy propagate the value
of x to its occurrence in (+ x 1) to produce 6, and will
propagate the values of both x and y to (* x y) to produce
30. This is true for library definitions, internal
definitions, and r6rs script definitions. The compiler
does not currently copy propagate across libraries (e.g.,
if x is defined in one library, y in another, and z in
a script). It also does not copy propagate if these
definitions are entered at the REPL since all definitions
in the interaction environment are mutable.
So, yes, the compiler will evaluate internal definitions
when it can (e.g., when the expressions do not perform
side effects). Keep in mind that all of this happens
at the optimizer, way after the program has been fully
expanded.
Aziz,,,