static variables?

Erik Max Francis max at alcyone.com
Wed Nov 20 18:19:16 EST 2002


Terry Reedy wrote:

> If I understand this, you are proposing that if a default is
> 'mutable', then extra magic be added to re-initialized (somehow) on
> every call.

I am doing no such thing.  I am simply stating that there is no a priori
reason why it _couldn't_ have been done that way.  It wasn't done that
way, and I am not suggesting it be changed, just justifying my position
that the way it's done right now is an arbitrary choice (simply because
it is the easiest to implement).

Whether the way it's currently done is a good idea is another question;
it seems from the constant confusion that this issue causes, it doesn't
seem so to me:  It causes confusion for newbies, and I can't think of
any circumstances in which you'd actually use that "feature" to your own
advantage that wouldn't be better expressed in clearer ways.

> > [For those about to mention the "But what if you really want x to be
> > None?" objection, one can simply use a private sentinel object.]
> 
> Ugh.  None *is* a (public, global) sentinel object.  Making it do some
> automagical special-case switcheroo behind the scenes in one
> particular context would complexify the language.  Making people do
> something more complex to get an obvious simple result strikes me as a
> wrong direction to go.

My parenthetical (well, bracketed) comment was simply to offset the
obvious complaint, "Well, what if I really did want to pass a None?"  If
you wanted to call f(None), you'd get the defaulting behavior, which
might not what be what you had wanted.  It would not have put the onus 
on the program to use the private sentinel object in any way.  (It was a
minor point anyway; and since None isn't mutable, it was really an
irrelevant comment anyway.)

-- 
 Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/
 __ San Jose, CA, USA / 37 20 N 121 53 W / &tSftDotIotE
/  \ Most men do not mature, they simply grow taller.
\__/ Leo Rosten
    Alcyone Systems' CatCam / http://www.catcam.com/
 What do your pets do all day while you're at work?  Find out.



More information about the Python-list mailing list