Comment on PEP-0238

Thomas Wouters thomas at xs4all.net
Mon Jul 9 10:16:50 CEST 2001


On Sun, Jul 08, 2001 at 08:02:27PM -0700, Bengt Richter wrote:

> >Doesn't fix the problems. What about this:
> >
> >semantics PRECISION, 0:
> >     x = 2/7
> >
> >semantics PRECISION, 100:
> >     print x

> I'm thinking that's trying to peek from one nested scope into another,
> and would be either illegal, trigger a special exception, or get you
> a NameError. I haven't thought this through, but that was
> part of the reason for a block rather than just setting global control
> parameters. I think only new bindings would be affected. Rebinding
> global names to stuff created within a semantic scope might have to carry
> environment along. I haven't thought that through either ;-)

Note that currently, only functions and classes introduce a new scope, not
other blocks like if, for, try, etc. And this still is no solution: if you
can't carry values from your 'precision scopes' to upper scopes, they are
useless black bloxes that eat everything that goes in :) And an explicit
'return x' is not going to change anything about the problem.

And what about this, for that matter:

def printme(x):
    semantics PRECISION, 100:
        print x

semantics PRECISION, 0:
    x = 2/7
    printme(x)

(or even with printme defined as

semantics PRECISION, 100:
    def printme(x):
        print x

:-)

-- 
Thomas Wouters <thomas at xs4all.net>

Hi! I'm a .signature virus! copy me into your .signature file to help me spread!




More information about the Python-list mailing list