Lisandro Dalcin wrote: > On Wed, Aug 20, 2008 at 9:28 PM, Greg Ewing <[EMAIL PROTECTED]> > wrote: >> Speaking of that, I've been thinking for a while now >> about making "not None" the default, and requiring >> "or None" to specify that None is an acceptable >> parameter value. > > Definitely +1 for me. > >> Having seen a number of pieces of Pyrex code that >> were susceptible to being crashed because "not None" >> wasn't used where it should have been, I think >> this would be a safer default. > > Indeed. My own code suffered for this flaw, I realized about this > Cython behavior reading the generated C code, and then I went to the > docs to comfirm this. Up to now, I'm not yet completelly sure that all > my code is free of "None" crashes. > >> The change may >> break some existing code, though. > > Yes, but surely is will make others codes to become correct.
But it does it by making a hard restriction on what kind of code you can write -- I'd like to be able to pass None to functions (in a safe manner), not just disable the feature. If you make this change now you essentially "can't go back" since you will then get code written which may depend on None being checked for at the beginning of the function. So it's a one way change, and we do get results more quickler but OTOH we permanently say no to (in my opinion) nicer behaviour. We all agree that segfaults are not nice, I just think the exception should be raised when accessing the field/attribute rather than when entering the function... (i.e. go the Java way like in the prototype I recently posted, see the behaviour in http://hg.cython.org/cython-dagss/file/4d543e06c926/tests/run/noneattributeacc.pyx ). Dag Sverre _______________________________________________ Cython-dev mailing list [email protected] http://codespeak.net/mailman/listinfo/cython-dev
