[Python-Dev] Re: Is outlawing-nested-import-* only an implementation issue?

Ka-Ping Yee ping@lfw.org
Thu, 1 Mar 2001 18:50:41 -0800 (PST)


On Fri, 23 Feb 2001, Jeremy Hylton wrote:
> I think the meaning of print x should be statically determined.  That
> is, the programmer should be able to determine the binding environment
> in which x will be resolved (for print x) by inspection of the code.

I haven't had time in a while to follow up on this thread, but i just
wanted to say that i think this is a reasonable and sane course of
action.  I see the flaws in the model i was advocating, and i'm sorry
for consuming all that time in the discussion.


-- ?!ng


Post Scriptum:

On Fri, 23 Feb 2001, Jeremy Hylton wrote:
>   KPY> I tried STk Scheme, guile, and elisp, and they all do this.
> 
> I guess I'm just dense then.  Can you show me an example?

The example is pretty much exactly what you wrote:

    (define (f)
        (eval '(define y 2))
        y)

It produced 2.

But several sources have confirmed that this is just bad implementation
behaviour, so i'm willing to consider that a red herring.  Believe it
or not, in some Schemes, the following actually happens!

            STk> (define x 1)
            x
            STk> (define (func flag)
                     (if flag (define x 2))
                     (lambda () (set! x 3)))
            func
            STk> ((func #t))
            STk> x
            1
            STk> ((func #f))
            STk> x
            3

More than one professor that i showed the above to screamed.