Python is DOOMED! Again!

Steven D'Aprano steve+comp.lang.python at pearwood.info
Mon Feb 2 02:18:48 EST 2015


Paul Rubin wrote:

> Chris Angelico <rosuav at gmail.com> writes:
>> So since you can set something to Nothing regardless of type, and
>> compare it against Nothing regardless of type, it doesn't really much
>> matter that there are different types of Nothing. Right?
> 
> No that's not how type inference works.  If you have x = Nothing and
> pass it to a function that takes a Maybe Int, type inference means the
> compiler figures out that x must have type Maybe Int.  If you then also
> pass x to something that takes Maybe String, you are telling the
> compiler that x has two different types at the same time, so the
> compiler reports a type error.

No apples and no oranges aren't the same thing, but if somebody is expecting 
no apples, and I give them no oranges instead, it would be churlish for them 
to complain that none of them are the wrong kind of fruit.



-- 
Steve




More information about the Python-list mailing list