[Python-Dev] Should Python compile as C++?

Tim Peters tim.one@comcast.net
Tue, 05 Feb 2002 07:28:27 -0500

Static initializers in C++ are much more liberal than in C, without the
latter's "constant expression" limitations.  This follows from that you
couldn't declare a static object of an arbitrary class otherwise:  C++ has
to be prepared to execute any code whatsoever in order to run user-coded

OTOH, because C++ is much more liberal in this respect, order of module
initialization is a much worse problem in C, and C++ doesn't define that any
more than C does.  Some of the worst debugging problems I ever had in C++
were tracking down quiet assumptions about initialization order that didn't
hold x-platform.  There are a number of well-known hacks in the C++ world
for worming around this, some of which explain why starting a large C++
program can give your disk a major workout.

As to making Python source compilable under C++, I quietly nudge it in that
direction.  If I explained why, it wouldn't be quiet anymore <wink>.