[Poll] Private variables

Christian Tanzer tanzer at swing.co.at
Mon Sep 17 01:40:47 EDT 2001


"Tim Peters" <tim_one at email.msn.com> wrote:

> [Tim, on Ref Man section 5.2.1 (Identifiers -- Private name mangling)]
> 
> [tanzer at swing.co.at]
> > When was this documentation added?
> 
> You can answer this as easily as I can -- it requires digging into the CVS
> history of ref5.tex (quickest is to do a CVS Annotate on SourceForge, using
> the ViewCVS web interface).

I could if I had online internet access at home (using uucp for
emails).

> > I don't remember reading that (back in 1.5.x times; of course, my brain
> > might just have chosen to selectively ignore it).
> 
> Or perhaps you never saw it.  It's in revision 1.17 of ref5.tex, though,
> which predates 1.5.2 alpha 1.  Tracing back further than that is difficult,
> because the Ref Man was also maintained under Framemaker before then, and
> there's no CVS history for that.

I found two old copies of the Ref Man on my machine: it was not 
documented in 1.4 (Framemaker), but it was there in 1.5.1 (LaTeX).

Not that it matters, though. Documenting obscure feature interactions
doesn't make them any better. 

> > Feature or bug, it still is an example of feature interaction waiting
> > to spring surprises on you.
> 
> Maybe.  This is the first time I heard of anyone having trouble with this,
> so I'm afraid I rank it somewhere below dividing by 0 accidentally <wink>.

Well, when I found this "feature" it was not important enough to write
up a complain. Besides, I figured the chances of it being changed were
slim. Judging by the style of your answer I was right on target here
<wink>.

I just wanted to warn to original poster about it when he asked about
the use of `__` names and was encouraged to use them.

> > ...
> > I understand the difficulty. I still think it would have been better
> > to just use a different (and documented) mangling scheme for class
> > names starting with a single underscore (like ___A_beep <shudder>).
> 
> Exactly the same difficulty:  that still looks like a private name (which
> begin with at least two underscores, not exactly two), so would be subject
> to further mangling when written literally.

Just learned something new. I didn't know that any number of two or
more leading `_` is considered private.

> You're unable to define a _Foo class and a Foo class in the same module
> without accidentally overlapping their namespaces?

How is the same module relevant for this issue? And what are `__`
names for if not to avoid overlap of class namespaces?

I stumbled over this because I use `__Ancestor` to chain up method
calls. [And don't tell me I should use `super` for this -- it's not
yet there!]

Promoting-a-wart-to-the-best-thing-since-sliced-bread-
    smells-funny-ly y'rs, 
Christian

-- 
Christian Tanzer                                         tanzer at swing.co.at
Glasauergasse 32                                       Tel: +43 1 876 62 36
A-1130 Vienna, Austria                                 Fax: +43 1 877 66 92





More information about the Python-list mailing list