> I don't have a specific proposal at the moment, but would invite > others to think creatively about ways to minimize cpp pollution while > still keeping the source readable and maintainable.
One possibility would be to change code like this.... #define XYZ 123 ....to this... namespace _PARROT { const int XYZ = 123; } By placing code in namespaces and not using CPP at all, name clashes are completely avoided. This requires the use of C++, rather than C. Also, where the CPP #define is nothing more than text substitution done at compile time, use of constants in C++ consumes runtine stack space. Dave Andy Dougherty <doughera@lafa To: Perl6 Internals <[EMAIL PROTECTED]> yette.edu> cc: Subject: CPP Namespace pollution 01/25/02 10:14 AM One problem noted recently on the p5p list is that if you do #include <perl.h> in your program, it exposes a *lot* of CPP #defines to your program, whether you want them or not. This is particularly a problem if you wish to embed perl or use it with an extensive 3rd-party library. For parrot, we'd ideally like to make it a lot safer to #include <parrot/parrot.h> Here's a status check on where we are currently: #include <parrot/parrot.h> currently #defines 198 global CPP symbols. If you take away the autoconf-ish HAS_HEADER_* and the proabably-quite-safe PARROT_* entries, that leaves 107 entries. Although it's impossible to predict what vendors and third-party software writers will do with the CPP namespace, the following 5 entries seem particularly likely to cause mischief at some point somewhere: Very general names: UNUSED INVALID_CHARACTER IO_ERROR KEY_NOT_FOUND Possible conflict with system headers: SSIZE_MAX This is #defined in parrot/io.h as 8192, but it's also possibly defined in the system headers as the maximum size of the Posix ssize_t type, typically INT_MAX or LONG_MAX. Since it's not used in parrot, I'm unsure of the intent. I don't have a specific proposal at the moment, but would invite others to think creatively about ways to minimize cpp pollution while still keeping the source readable and maintainable. -- Andy Dougherty [EMAIL PROTECTED] Dept. of Physics Lafayette College, Easton PA 18042