[C++-SIG] Python calling C++ issues

Geoffrey Furnish furnish at actel.com
Wed Dec 1 23:37:01 CET 1999


For the list: The most contentious aspects of this tiff are being
handled in private email.  However I would like to comment publicly on
one aspect of Guido's post:

Guido van Rossum writes:
 > Rant aside, what compiler is going to support different datatype sizes
 > for stuff declared extern "C" than for native C++ types?  Get real.

One of my personal beefs with the casting to PyCFunction, has nothing
to do with the (illegal according to strict C++ rules) presumptions
about function pointer compatibility.  There is also the issue of just
exactly what the function signature is.  The Python C implementation
actually casts all function pointers to PyCFunction, even if they have
different arg lists!  The fact that this is illegal by C++ language
rules is almost the least of all concerns!  The size of the pointer
type is almost irrelevant.  Here we have type information (the
function invocation arg list) being communicated through independent
parameters.

Okay, fine, there aren't a lot of choices in C.  Whatever.  In C++
though, the compiler actually supports a decent type system, and there 
really is no reason to attempt to subvert the C++ type system and
reincarnate its soul in the form of extraneous parameters, whose
definitions have to be predetermined and extensions to which cannot be 
properly anticipated by the implementor.

These sorts of problems can be solved in C++ by letting the compiler's 
type system do the work for you.  For this case in question, probably
its going to have to mean some template trampolines and all the
associated machinery.  And unfortunately, this reliance upon templates 
has caused a lot of fuss on this SIG.

Frnakly, I don't want to get into a C versus C++ style debate.  I
really couldn't care less how people write their C code.  Observe that
I have never posted to c.l.p suggesting that "Python's implementation
would be a lot nicer if it was swtiched from C to C++".  That does
happen to be my personal oppinion, but I don't advocate it publicly
because such advocacy isn't going to change the situation, and just
creates needless stir and resentment.

But by the same token, I really don't think it's fair for people with
an ax to grind against C++ to use the C++ SIG to vent about how
dogmatic the C++ camp is.

Seriously, couldn't we all just calm down and work on solving the
problem? 

-- 
Geoffrey Furnish            Actel Corporation        furnish at actel.com
Senior Staff Engineer      955 East Arques Ave       voice: 408-522-7528
Placement & Routing     Sunnyvale, CA   94086-4533   fax:   408-328-2303

"... because only those who write the code truly control the project."
						      -- Jamie Zawinski




More information about the Cplusplus-sig mailing list