On May 6, 2009, at 1:33 PM, Dag Sverre Seljebotn wrote:

> Robert Bradshaw wrote:
>> On May 6, 2009, at 12:48 PM, Dag Sverre Seljebotn wrote:
>>
>>> Robert Bradshaw wrote:
>>>> Just trying to get a syntax, how about
>>>>
>>>> cdef extern from "header.h":
>>>>      cdef cclass MyClass[TemplateParamers](BaseCPPClass):
>>>>          int member
>>>>          int method(int)
>>>>
>>>> The only concern I have is whether or not "cdef cclass" is to  
>>>> similar
>>>> to "cdef class" (probably not). Any other ideas?
>>>
>>> cdef cppclass?
>>
>> I don't like this one, but I think just for aesthetic reasons. Nor
>> cpp_class.
>
> Myself I'm used to a .cpp suffix on C++ files; I suppose people who  
> are
> used to the competing .cc will have stronger associations with your
> proposal. "cclass" gives me no associations at all initially.

I could get used to cppclass, but I'm hoping someone comes up with a  
name that's obviously the "right" one :).

>>> Yes, I think cclass is to similar to class.
>>>
>>> Anyway, when I proposed a Fortran syntax earlier you and Stefan  
>>> made a
>>> good point about the language specification belonging in the "cdef
>>> extern"
>>> part, as, after all, the "header.h" file contains only C++ code.
>>
>> Will the compiler need to know that header.h is C++ code? If not, I
>> see no reason to declare it.
>
> No -- it's just the fact that usually all classes within the extern  
> block
> will be a C++ class. I was thinking just plain "cdef class" could then
> change meaning, which would have a happy association with the
> heap-allocation thing (which C++ classes would share with existing  
> cdef
> classes).
>
> cdef extern "C++" from "myheader.h":
>     cdef class A: ...

I'm -1 on having "cdef class" mean two very different things.

> OTOH, if heap-allocation-and-refcounted semantics isn't selected, one
> should use "cdef struct" instead, like Lisandro suggests.

Structs are also something different (well, there's a lot of  
similarity, but the idea of inheritance is a big one), especially if  
we're looking at heap allocated classes for the first iteration. (I  
don't think we want to try to do our own refcounting, let the user  
use new and delete directly if they want to use C++.)

- Robert

>

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

Reply via email to