Dag Sverre Seljebotn, 13.04.2010 16:28:
> Stefan Behnel wrote:
>> Dag Sverre Seljebotn, 13.04.2010 09:11:
>>
>>> The argument against changing the default is simply that there is
>>> another option which is much closer to Python semantics
>>>
>>
>> I think the "another option" bit in this sentence is at the core of our
>> disagreement. My point is that incorrect input should be caught early, and
>> None is incorrect (and dangerous) input in almost all cases where a typed
>> value is expected. So rejecting this dangerous input should be the default.
>
> I'll just repeat Robert: I think the core of the disagreement is that
>
> def f(X x):
> ...
>
> should correspond directly to
>
> def f(obj):
> cdef X x = obj
>
> I.e., no special casing of arguments vs. other typed variables.
Yes, I disagree with that, simply because they already are different. You
can't do
cdef X not None x = obj
but you can do
cdef X x = <X?>obj
to mimic the "not None" semantics. You can't do the same thing for
arguments, though, where the requirement is much more common. That's why
there is a dedicated syntax, just the wrong one.
> This is simply because anything else is not going to be obvious to
> anybody learning the language. It's seems very complicated to hold a
> Cython tutorial where I have to explain that "MyType myvar" means
> something else for function arguments than in local variable or class
> field declarations.
>
> If you want to propose that
>
> cdef X x = None
>
> is also disallowed, then that's something else entirely.
I'm not proposing that because it doesn't make sense without supporting
'del' and control flow analysis correctly. Otherwise, it would be
impossible to reset a typed reference or to initialise it with an 'empty'
value. Input parameters are an entirely different beast.
I think we should stick to helpful examples, so I guess a CEP is really
required.
Stefan
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev