Robert Bradshaw wrote:
> On May 7, 2009, at 5:03 AM, Dag Sverre Seljebotn wrote:
>> 3) Just tracking the first assignment, and destruct at end of  
>> function,
>> would kind of work, but there's a problem: Basically the first
>> assignment must invoke placement new, while subsequent assignments  
>> must
>> use "=".
>>
>> This could be dealt with with a seperate flag though! So you have a  
>> flag
>> "is_constructed", and if it is not, use placement new for assignment,
>> otherwise use "=".
>>
>> As for eliminating such a flag, it would be easy to support
>>
>> cdef iterator it
>> it = vec1.begin() # placement new
>> if not foo:
>>      it = vec2.begin() # "="
>>
>> but much more difficult to support
>>
>> if foo:
>>    it = vec1.begin() # placement new
>> else:
>>    it = vec2.begin() # placement new
>>
>> and impossible to do
>>
>> if foo:
>>    it = vec1.begin()
>> it = vec2.begin() # placement new or "="? need a flag
>>
>> Still, using such a flag in all situations before we have control flow
>> analysis is a lot better than refcounting until we have control flow
>> analysis :-)
>>
>> Finally, we could still have an explicit
>>
>> destruct(it)
>>
>> which would also toggle the flag back, making the next assignment
>> reconstruct the object.
>>
>> This would actually work :-) (assuming void*[] is all the alignment we
>> need).
> 
> I much prefer option (3), that seems both feasible and obvious to use.

+1, makes sense to me.

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

Reply via email to