[Python-ideas] Python Numbers as Human Concept Decimal System

Paul Moore p.f.moore at gmail.com
Tue Mar 11 16:26:34 CET 2014


On 11 March 2014 15:14, Antoine Pitrou <solipsis at pitrou.net> wrote:
>> The problem is that the context cannot be depended upon so the result
>> of trivial calculations or even a negative decimal literal will depend
>> on something that can be changed *anywhere* else in the code. The
>> expression -1.123456789d will evaluate differently depending on the
>> context and I think many people will be surprised by that. I expect
>> that this would lead to naive code that breaks when the context is
>> changed. Great care needs to be taken to get this right, or otherwise
>> it should just be considered generally unsafe to change the context.
>
> This is a good point, but I still don't think it outweighs the large
> cognitive baggage (and maintenance overhead for library authors as well as
> ourselves) of having two different types doing mostly similar things.

It feels to me as if what we're discovering here is why dynamic
scoping is a bad thing. If context was lexically scoped, all of this
concern about "action at a distance" and user code impacting library
behaviour would go away.

I presume that ship has sailed, though, and there's no practical way
of switching to lexical scoping of decimal contexts...

Paul


More information about the Python-ideas mailing list