Comment on PEP-0238

Bengt Richter bokr at accessone.com
Sun Jul 8 23:02:27 EDT 2001


At 01:52 2001-07-09 +0200, Thomas Wouters wrote:
>On Sun, Jul 08, 2001 at 10:45:12PM +0000, Bengt Richter wrote:
>
> > Why not parameterize the concept with a single block-scope-introducing
> > keyword, e.g., 'semantics' or 'special' e.g., rewriting from above:
>
> > semantics PRECISION, 0: # everything behaves as it does now
> >     print 2 / 7    # -> 0, ie to precision 0 decimal places
> >     print 2/7.0   # -> 0.285714285714
>
> > semantics PRECISION 1:   # all calculations yield 1 decimal point
> >     print 2 / 7    # -> 0.2, ie to precision 1 decimal places
>
>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 ;-)

Regards,
Bengt Richter
P.S. I'm not a list subscriber, just reading the newsgroup, so I'm
not sure what is going where, but this is an email reply with cc to list.
Hope that's ok ;-)





More information about the Python-list mailing list