On May 6, 2009, at 11:05 PM, Stefan Behnel wrote:

>
> Greg Ewing wrote:
>> Robert Bradshaw wrote:
>>> On May 6, 2009, at 1:33 PM, Dag Sverre Seljebotn wrote:
>>>> cdef extern "C++" from "myheader.h":
>>>>    cdef class A: ...
>>
>> For Pyrex I'm thinking about using "cdef+" as a
>> general prefix for C++-related declarations, e.g.
>>
>>    cdef+ extern from "myheader.hpp":
>>      ...
>>
>>    cdef+ struct Foo:
>>      ...
>
> ... and if we ever support the D language, we'd need a 'ddef' or  
> 'cdefd'?
>
> What about using some kind of qualifier as above, but more like
>
>       cdef[c++] extern ...
>
> or
>
>       cdef(c++) extern ...
>
> or even
>
>       cdef("c++") extern ...
>
> to come a bit closer to pure Python code.
>
> That would be easily extensible to
>
>       cdef[fortran] ...
>       cdef[D]
>
> and would simply default to
>
>       cdef[C]
>
> if no qualifier is provided in a plain "cdef".

Parameterized keywords? Sorry, but that hurts my eyes... :(

The only time we'd need to declare a language is for external  
declarations. I'd rather have

cdef extern from "foo.h" language "cpp":
     ...

or

cdef extern from cpp "foo.h":
     ...

Actually, the whole cdef keyword here is redundant, maybe one could  
just write "extern from ..." (though I do like the fact that nearly  
all non-Python syntax/blocks begin with a cdef).

I think this is somewhat tangential to the question of how to declare  
classes, unless one wants "class" or "struct" to have new meanings in  
different contexts (which I don't like).

- Robert

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

Reply via email to