Hi,

Robert Bradshaw wrote:
> To me the idea that exactly one of
> 
> def foo(ExtType x):
>      ...
> 
> cdef foo(ExtType x):
>      ...
> 
> can accept None, and the other throws an error, is counterintuitive. I do 
> see a difference (def functions are exposed to the "outside world") but I 
> think people are just as likely to shoot themselves in the foot with the 
> second option as well.

FWIW, I'm with Robert here. Having automatic argument checking in one special
(and very visible) place will let users forget to do the checking themselves
in the other places, which might even increase the chance of writing broken 
code.

I'm also not sure I find it counter-intuitive that a declared extension type
parameter cannot contain None. All Python references can be None, so why not
that one? I think there are about as many reasons why people would expect one
behaviour as for expecting the other.


> And people will still have to be careful with
> 
> cdef ExtType x = foo()
> x.cdef_attribute

It would be nice if this could be solved by better flow analysis, but I doubt
that it can be achieved with reasonable effort.

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

Reply via email to