On Tue, Oct 6, 2009 at 4:03 PM, Robert Bradshaw <rober...@math.washington.edu> wrote: > > c99_complex is an internal directive (and I (intentionally) didn't > add it to the list of directives because I wasn't sure if that's the > final interface we wanted), so I think we're safe to change it. I'm > starting to wonder if we even need it at all.
I think we need it... you know how much I hate second guessing... I've never liked that of c99 complex being on depending of "complex.h" being included... Moreover, going C++, I do not know how to detect if <complex> was #include's ... > Rather, we could use > struct-based complexes by default, but if complex.h is included > (detected by looking for the specific macros it defines) either c99 > or C++ complexes would be used. I have an alternative proposal: Let's call the directive 'ccomplex' (in the spirit of cdivision, which applies both to C and C++)... Cython generates code to support struct-based complexes, C99 _Complex in C, and std::complex<> in C++... there is a C macro PYX_USE_CCOMPLEX that let choose the struct based implementation or the C99/C++ (depending on defined(__cplusplus))... Then the ONLY effect of the directive 'ccomplex=True' would be to make the macro PYX_USE_CCOMPLEX be 1 be default... BUT if at C compile time PYX_USE_CCOMPLEX is set to 0, then the struct-based impl is used.... Similarly, if 'ccomplex=False' (the default), then PYX_USE_CCOMPLEX defaults to 0, BUT again if at C compile time PYX_USE_CCOMPLEX is defined to 1, then the C99 or C++ versions are used depending on __cplusplus... What do you think? I really like this.. > All arithmetic (including getting/ > setting the real/imag parts) would be done via macros. > Of course. Though I anticipate problems the setter/getter for real/imag ... I do think we should have {SET|GET}_{REAL|IMAG} part, if not we will not be able to support C++0x ... Also, currently the C99 support is using __real__/__imag__ > This is essentially the current default behavior, except we'd add > support for C++ complexes in place of c99 complexes if, at C compile > time, the language is determined to be C++. > -- Lisandro Dalcín --------------- Centro Internacional de Métodos Computacionales en Ingeniería (CIMEC) Instituto de Desarrollo Tecnológico para la Industria Química (INTEC) Consejo Nacional de Investigaciones Científicas y Técnicas (CONICET) PTLC - Güemes 3450, (3000) Santa Fe, Argentina Tel/Fax: +54-(0)342-451.1594 _______________________________________________ Cython-dev mailing list Cython-dev@codespeak.net http://codespeak.net/mailman/listinfo/cython-dev