Dag Sverre Seljebotn wrote:
> Robert Bradshaw wrote:
>> Very good point. I've forwarded this onto Danilo who's working on C++  
>> support.
>>
>> On Jul 23, 2009, at 12:56 PM, Martin Albrecht wrote:
>>
>>>> 1) Do you have any priorities for features you'd like to see sooner
>>>> rather than later?
>>> While debugging and fixing an issue in the current PolyBoRi wrapper  
>>> with
>>> Alexander Dreyer we noticed the following behaviour in Cython which  
>>> doesn't
>>> mix well with C++:
>>>
>>> Consider the following code:
>>>
>>> cdef BoolePolyRing ring = pbenv_ring()
>>>
>>> where pbenv_ring() returns a reference to the currently active  
>>> PolyBoRi ring.
>>>
>>> This is fine because Cython doesn't care whether a variable or a  
>>> reference is
>>> returned. However, Cython re-arranges the code as follows internally:
>>>
>>> cdef BoolePolyRing ring
>>> ring  = pbenv_ring()
>>>
>>> This is fine if BoolePolyRing is a C data structure because in C  
>>> declaration
>>> is never code execution. However, this is not fine in C++ where  
>>> declaration
>>> may be code execution: the default constructor.
>>>
>>> (In our case the default constructor for BoolePolyRing would define  
>>> a new ring
>>> and mark it as active and thus render the later assignment useless)
>>>
>>> So my nr.1 feature request is to not re-arrange declarations if C++  
>>> is the
>>> language Cython compiles to.
> 
> Note that this alone will not solve very much -- it will still only work 
> for classes with constructors without arguments. Just doing this would 
> just waste time IMO.
> 
> This particular problem has been discussed to great length on the Cython 
> list several times -- to recap quickly:
> 
> 1) At first, one should probably disallow code like that (all C++ 
> classes must only be used through pointers -- so "cdef BoolePolyRing* 
> ring").


Sorry, please ignore this:

> 
> Note that without further definition of how this should work,
> 
> ring = pbenv_ring()
> 
> is nonsense anyway ("cdef BoolePolyRing ring" means stack allocated 
> memory, not reference counted or similar).

I realize what you mean now.


-- 
Dag Sverre

--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to