Robert Bradshaw wrote:
> On May 7, 2009, at 2:47 AM, Dag Sverre Seljebotn wrote:
> reason to go with structs in the first place). This is almost
> sounding like a proposal to do
>
> cdef managed CWidget
>
> which would be an object wrapping a CWidget.
Perhaps that is a better way to think about it.
Still, introducing that as the direct way of wrapping C++ classes
sidesteps the issue of figuring out how C++ semantics should work in
Cython (just in order to be wrapped).
>> I still believe it should be discussed now because
>> a) it heavily impacts how one thinks about C++ operators
>
> Yes.
>
>> b) it is a way to solve the construction/destruction problem with C+
>> + classes
>
> I'm not sure it does.
I am referring to having to do it[0][0], which is needed because one
cannot do
cdef vector[int].iterator it
currently.
With my proposal you can do
cdef vector[int].iterator it
print it is None # True
it = vec.begin()
while it != vec.end(): # != would go through to wrapped objects
print deref(it) # it.get() with my operator proposal
inc(it) # it.next() with my operator proposal
which is a "solved" in my book.
(I've let inc operate in-place here, so that "b = a; inc(a)" would
modify b as well. As if inc is calling a method on a. If you did
while it != vec.end():
...
it += 1
then you would start craving stack-allocation optimizations as this
would have an malloc per iteration; but that's not too hard, just notice
that "it" is never referenced directly anywhere (only used in
operations) and so it can go on the stack instead).
--
Dag Sverre
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev