On Sep 16, 2009, at 7:45 AM, Lisandro Dalcin wrote:

> On Wed, Sep 16, 2009 at 5:49 AM, Dag Sverre Seljebotn
> <[email protected]> wrote:
>> Stefan Behnel wrote:
>>> Dag Sverre Seljebotn wrote:
>>>
>>>> A directive to warn/give error on any undeclared variables? I.e.:
>>>>
>>>> @cython.warning_undeclared(True)
>>>> def foo():
>>>>     cdef object a
>>>>     cdef int b
>>>>     a = b = c  = 3 # warns that "c" is not declared and auto- 
>>>> typed to object
>>>>
>>>
>
> Dag, take for granted that anything that Cython adds in this
> direction, I'm going to use once it is ready... and likely these
> directives will be globally enabled by default.
>
> However, there is something that makes me uncomfortable about this...
> This is not quite similar to other compiler directives... I mean, it
> has no effect in Cython semantics or generated C code. Just a coment,
> not a big deal...
>
> In the same spirit, Cython could have a "directive" to emit warnings
> when a bare "object" is implicitly cast to a  builtin/cdef type.
>
> Final note: we could potentially have many warning-related directives,
> right? Having a lot will not harm, right? Then perhaps we should have
> a dict-like "warning" directive, and you use like this:
>
> @cython.warning(undeclared=True,untyped=True,cast_implicit=True)
> cdef void foo(a): # "a" is untyped
>     cdef list b
>     cdef object c
>     b = a # implicit downcast object -> list
>     c = b
>     d = c # 'd' undeclared

+1 I like this warning decorator. Perhaps we could also take a -Wxxx  
flags like gcc. I'd rather it not be on by default however.

- Robert

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

Reply via email to