Hi,

Just for the record :)

On Thu 23 Jul 2009 18:13, Mark H Weaver <m...@netris.org> writes:

> On Thu, Jul 23, 2009 at 05:24:30PM +0200, Marijn Schouten (hkBst) wrote:
>> For the calls above all the dynamic accesses can be determined statically.
>> Lexical accesses can always be determined statically. Thus all accesses in 
>> this
>> example can be determined statically and can be compiled to a location
>> dereference (either read or write). Nothing in the semantics is inherently
>> inefficient.
>
> There is at least one inherent loss of efficiency with the semantics
> you propose: with a lexical-let binding, the compiler can determine
> statically whether the variable is non-mutable, because the only place
> it could possibly be set! is within the lexical scope.  Non-mutable
> variables can safely be inlined, an especially important optimization,
> especially if the value is a procedure.

Guile does detect this. The useful optimization is that variables that
are never set! can be allocated on the stack, and if they're closed
over, they can simply be copied.

> Also, with lexical-let, the compiler knows statically the entire set
> of references, which can be helpful with many analyses, for example
> whether continuations or closures can "escape" a particular scope,
> whether a particular continuation might be invoked more than once,
> etc.

This is a more tricky optimization :)

Andy
-- 
http://wingolog.org/


Reply via email to