Stefan Behnel wrote:
> Dag Sverre Seljebotn, 13.04.2010 08:19:
>> Also there's the big advantage of allowing code like
>>
>> def f(MyClass arg=None):
>>      if arg is None:
>>          arg = new_default_instance()
>>      print arg.x
>>
>> without any "allow None".
> 
> Sorry, but that case is so trivial to handle implicitly that I can't see 
> how this is supposed to be an argument against changing the default.
> 

The argument against changing the default is simply that there is 
another option which is much closer to Python semantics (and IMHO more 
user friendly as the user don't have to care about declaring "not None" 
manually).

Java has had decent "None" behaviour for ages using control flow 
analysis, so it can definitely be done. As Robert says, it is just about 
moving the check (that should happen at some point anyway) to the point 
of first attribute access in a code path and then raise the exception 
there, just like Python would.

-- 
Dag Sverre
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to