toki doki wrote:
> On Mon, Jul 5, 2010 at 6:15 PM, Stefan Behnel <[email protected]> wrote:
>   
>> Dag Sverre Seljebotn, 05.07.2010 10:56:
>>     
>>> the example toki doki posted gets ugly, as one needs to do
>>>
>>> foo = vect.at(4)[0] + 10
>>>
>>> to get the equivalent of the C++ "foo = vect.at(4) + 10".
>>>       
>> What's so ugly about that?
>>
>> Stefan
>> _______________________________________________
>>     
>
> Well, I was just concerned that many users might unintentionnally
> write " foo=vect.at(4)+10 " when they meant " foo=vect.at(4)[0]+10 ".
> If foo is declared to be an unsigned int or a pointer, there might not
> be any warning from the compiler. And that could result in a bug very
> difficult to understand.
>
> An (ugly) example:
>
> """"""""
> cdef vector[void **] vect
> cdef void *foo
> # Assume that vect has been populated with meaningful pointers
> foo= vect.at(2)[3]   # foo is equal to  vect[5] instead of vect[2][3]
> """"""""
> In the above code, no compiler warnings will tell the user that he did
> something wrong. It will be very difficult for him to understand what
> is the problem. One could say that somebody using vectors of void**
> beg to be punished. Still, it is possible there exist more valid
> examples.
>
> Also, the issue of how to write " *foo=bar " when foo is a general
> iterator remains. (one cannot write " operator.dereference(foo)=bar
> ").
>   
Argh, yes that is a real problem. The easiest way of assigning to items 
in a C++ list<int> would be this?

(&(cython.dereference(my_iterator)))[0] = value

Hmmm...

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

Reply via email to