On Wed, Jun 24, 2009 at 1:10 PM, Robert
Bradshaw<[email protected]> wrote:
> On Jun 23, 2009, at 4:44 AM, Dag Sverre Seljebotn wrote:
>
>> Jon Olav Vik wrote:
>>> Jon Olav Vik <jono...@...> writes:
>>>> == cynvector.pxd ==
>>>> from sundials cimport * # sundials.pxd defines N_Vector
>>>> cdef class CythonNVector:
>>>>     cdef N_Vector nvector
>>>>     cpdef toarray(self)
>>>> == cynvector.pyx ==
>>> [...]
>>>> cdef class CythonNVector:
>>>>     cdef N_Vector nvector # <-- ERROR
>>> [...]
>>>
>>> Gotcha: When I copied declarations from cynvector.pyx to
>>> cynvector.pxd, I
>>> should have removed the original "cdef N_Vector nvector" from
>>> the .pyx file. As
>>> it was, I got a "'nvector' redeclared" error when re-compiling my
>>> example. The
>>> reason I didn't see it at first is that I compiled cynvector.so
>>> just from
>>> cynvector.pyx first, before creating cynvector.pxd.
>>>
>>> To summarize: "Formal" declarations of object attributes in
>>> filename.pxd are
>>> automatically available in filename.pyx and should not be repeated
>>> there.
>>> (Functions and class definitions _are_ repeated, for implementation.)
>>
>> This confused me a lot too when I met it the first time. Could we
>> change
>> this? That is, I think we should start silently accept/ignore
>> repeating
>> the declaration of cdef class fields (and module global variables?) in
>> the pyx -- this should be backwards compatible.
>
> I'm not opposed to such a change. Errors, of course, on non-matching
> and extra fields.
>

I´m not opposed to. However, I think that the pyx file should declare
nothing, or it should repeat ALL the declaration on the pxd, with
MATCHING TYPES and even in the SAME ORDER... If not, you just open the
door to more confussion and possible bugs (when the pxd is
cimported)...



-- 
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