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



-- 
Lisandro Dalcín
---------------
Centro Internacional de Métodos Computacionales en Ingeniería (CIMEC)
Instituto de Desarrollo Tecnológico para la Industria Química (INTEC)
Consejo Nacional de Investigaciones Científicas y Técnicas (CONICET)
PTLC - Güemes 3450, (3000) Santa Fe, Argentina
Tel/Fax: +54-(0)342-451.1594
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to