On Apr 27, 2009, at 8:05 PM, Danilo Freitas wrote:

> Gettin all together, we want:

Well, it's a proposal.

> cdef extern from "foo.h":
>     cclass Foo:  # or whatever else we come up with here
>         Foo __add__(Foo, Foo)
>         Foo __add__(Foo, int)
>         int __dereference__(Foo)
>         Foo __increment__(Foo) #different of inc(), right?
>         cpp_Iterator __iter__() #or something like this
>
> foo = Foo()
> for inc() and dec(), there are many ways to do it;
>
> it = foo.begin()
> it = get_begin_iterator(foo) #or cython.get_begin_iterator(foo)

I'd much rather have foo.begin(), but here there might be a question  
of allocation...

> with types:
>
> cdef cpp_Iterator it = foo.begin()
> ...
>
> and to use in() and dec():
>
> cython.inc(it)
> foo.inc(it) #this way, it's possible to customize your own inc()  
> and dec()
> it.inc()

The problem with foo.inc() is that there might be a class method  
named inc that is completely orthogonal to ++.

> we just need to find the better way to use these functions/methods.
>
> I think it would be the same for deref (only on syntax, no custom
> implementation)

Yep.

In terms of summarizing the discussion, it would be nice to have a  
page (e.g. http://wiki.cython.org/cpp/operators ) that listed a big  
table all operators in C++ (with grouping, e.g. binary arithmetic  
operators don't need individual treatment) and if/how we'd plan on  
supporting them in Cython (this has two parts--how to declare, and  
how to invoke).

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

Reply via email to