Class Friends

Alex Martelli aleaxit at yahoo.com
Fri Aug 27 17:18:19 EDT 2004


Jeremy Bowers <jerf at jerf.org> wrote:

> On Fri, 27 Aug 2004 20:37:44 +0200, Alex Martelli wrote:
> 
> > Anthony Baxter <anthonybaxter at gmail.com> wrote:
> >    ...
> >> I've considered a jihad to try and get uses of the double-under
> >> mangling removed from the standard library. Maybe once 2.4 is out I'll
> >> take this on.
> > 
> > Count on my support on this: I consider it "something that looked like
> > it would be a good idea at the time" (to me, too -- I'm not prescient
> > either;-) but didn't really work as well as hoped.
> 
> Well, I didn't want to come right out and say it for fear of starting a
> flame war, but yeah, I was thinking this really loudly :-)
> 
> (At least it is only for *double* underscores; mangling on singles would
> have *really* sucked.)

Yeah, it would.  Mind you, accidental clashes with a base class's
internals _do_ happen, and it IS a pity there's no easy and elegant way
to avoid them, but it currently seems to me (after a few years'
experience, and starting with a positive bias towards the idea) that
mangling on double underscores, as Anthony says, has enough issues to
make it not ideal for the purpose.  So, we need to keep that mechanism
in the language, for backwards compatibility (and perhaps as a sneaky
way to claim we DO so have 'private'...!-)... but we sure don't need to
use it ourselves if it gives us more problems than it solves.

Just like the (more practically important) problem of sandboxing (ever
since rexec and Bastion got deprecated), the problem of avoiding
accidental clashes between ancestor and descendant classes, without
paying a substantial price for it, may perhaps be currently classed as
'unsolved -- as yet'.


Alex



More information about the Python-list mailing list