guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: guile for lisp set


From: Neil Jerram
Subject: Re: guile for lisp set
Date: 10 Dec 2000 17:58:59 +0000

>>>>> "Marius" == Marius Vollmer <address@hidden> writes:

    >> I would like to use the following code as part of an
    >> explanation of closure:
    >> 
    >> (define tt (let ((s 5)) (lambda () (write (local-eval (read)
    >> (the-environment))) (newline))))

    Marius> This is a good explanation of `local-eval', but I don't
    Marius> think you should use local-eval to explain the much more
    Marius> basic concept of closures and lexical scope.  It might be
    Marius> an advanced example for the very curious at the end of the
    Marius> section on closures (sort of with a triple dangerous bend
    Marius> sign, if you know the TeXbook), but the essence of lexical
    Marius> scope should be explained without referring to it.

Agreed.  I have now used other, more standard examples in my
explanation of scoping and closure.  ((guile)About Closure, BTW.)  I
think I will keep this example for the documentation of `local-eval'.

    >> Will Guile always have (AFAYK) something like the-environment
    >> and local-eval to permit referencing and using a local
    >> environment?

    Marius> I don't know.  One important property of lexical scope is
    Marius> that the data structures used to implement the local
    Marius> environment are completely at the discretion of the
    Marius> compiler.  It can use a different, optimized
    Marius> implementation for every chunk of code that has access to
    Marius> that environment.  And because the scope is lexical, the
    Marius> compiler can readily identify that chunk of code and
    Marius> doesn't need to tell anyone how it represents its
    Marius> environments.

    Marius> `the-environment' and `local-eval' would have to know
    Marius> about the implementation of environments.  I'd say that
    Marius> this restricts a compiler significantly.

Indeed: without `the-environment' and `local-eval', a compiler (and
also an interpreter?) can unreference any environment bindings that
are explicitly used by the memoized/compiled code.

Regards,
        Neil



reply via email to

[Prev in Thread] Current Thread [Next in Thread]