> Well, what is the syntax going to be for other operators? I.e. I would
> think you could have either
For now, we still didn't think on it. It may be another question for
vote. We could expand this thread for voting also on the syntax for
the other operators (like the constructor, the work should be the
same).
> cdef extern cppclass Foo: # or whatever
> Foo(int a, int b)
> Foo operator+(Foo other)
>
> or
>
> cdef extern cppclass Foo:
> def __init__(self, int a, int b)
> def Foo __add__(self, Foo other)
>
> or
>
> cdef extern cppclass Foo:
> cdef __init__(self, int a, int b)
> cdef Foo __add__(self, Foo other)
>
> but I wouldn't feel happy about a mixture of those.
Yep. Allowing different syntax for constructor and operators would be
weird. Defining a 'default' is better.
To let people know better here, the syntax for defining C++ classes is
(using an example file for tests):
cdef extern from "foo.h" namespace something: #namespace is optional
cdef cppclass Foo:
int do_something(int)
cdef cppclass Foo2(Foo): #inheritance allowed
pass
cdef Foo *make_Foo():
pass
cdef Foo2 *make_Foo2()
cdef Foo *a = make_Foo()
cdef Foo2 *b = make_Foo2()
We can declare methods inside the class without the cdef, so, taking
this to constructors and operators should be allowed too.
Also, objects declared inside a C++ class are taken as C types (Python
objects not allowed)
So, a C++ class won't have any Python object as member. We'll just get
the already existing syntax.
Robert may explain better this part of the project.
--
- Danilo Freitas
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev