Protected Methods and Python

Alex Martelli aleax at aleax.it
Sun Apr 13 17:53:02 EDT 2003


Roy Smith wrote:

> Alex Martelli <aleax at aleax.it> wrote:
>> #define private public
>> #define protected public
>> at the top of your .cpp file, before any #include, in most C++
>> implementations
> 
> I'm confused.  You started out to show that C++'s "protected" keyword is
> evil,

I did no such thing -- I just mentioned Stroustrup's regrets about it (and
my agreement with him on this point).  It's more of a redundant complexity
than any substantial "evil".

> but what you've really shown is that C++'s preprocessor is evil.

Nope.  If your preprocessor didn't implement #define, you could do
just the same trick, even more messily, with a copy and paste from
the relevant .h files and any text editor of your choice.  The
preprocessor just makes it handier, avoiding the evils of copy and
paste coding for this, at least;-).

> Can they both be true? :-)

Possibly, but that's not what we're discussing, anyway.


Alex





More information about the Python-list mailing list