On Jan 29, 2010, at 2:25 AM, Stefan Behnel wrote:

>
> Danilo Freitas, 29.01.2010 04:34:
>> As you know, Robert is planning to put the work about C++ Support in
>> next release. So, we have some new stuff, and people need to learn  
>> it.
>>
>> I wrote a very simple tutorial on wiki [0], with some examples. I
>> think it's easy to learn (and use) it.
>
> Thanks, there seems to be a lot in there (feature-wise).
>
>
>> So, if you have any questions about it, just ask here.
>>
>> [0] http://wiki.cython.org/gsoc09/daniloaf/progress
>
> One thing that strikes me: Is "new" a keyword now?

"new" was chosen because of the symmetry between new and del (if one  
allocates, one needs to delete), and it would be easy for C++ people  
to understand. Calling the constructor directly returns an object by  
value, not a heap allocated one. (How to best handle objects returned  
by value is an open question...) Note that the lack of block-level  
scoping, and the c89/MSVC requirement of pre-declaring all variables  
at the top, makes stack allocated C classes a stickier problem,  
necessitating good support for new.

> I don't find that a good
> idea - it will break existing code at best. Why was this chosen over
> something like "cython.new()"?

How would cython.new be used to invoke a constructor?

cdef extern from "a.h":
     cdef cppclass A:
         A(int, int)

cdef *A = cython.new(A(2,3)) #?
cdef *A = cython.new(A, 2, 3) #?

> Or is it only enabled when compiling C++
> code? That would be bad enough, but would at least make it less  
> likely to
> break code.

I think this is an easy issue to work around--the original grammar  
would prohibit new as an identifier in this context anyway.

- Robert


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

Reply via email to