How much is set in stone?

Roeland Rengelink r.b.rigilink at chello.nl
Tue Nov 6 02:58:14 CET 2001


Jive Dadson wrote:
> 
> Roeland Rengelink wrote:
> >
> > Jive Dadson wrote:

<snip>

> > > You must have misunderstood what I wrote.  I'm not proposing anything
> > > that would make it "lowly dynamic".
> > >
> >
> > Well, you use the term 'variable declaration' which for most of us
> > carries the connotation of both the definition of a name, and a
> > restriction of the type of values that can be assigned to it. aka static
> > typing.
> 

> If you had read what I wrote, you would know I didn't mean anything like
> that.
> 

Since, in the next paragraph, I acknowledged that you didn't mean that,
I'm somewhat surprised by that remark. Let me quote myself:

> However, I gather from the rest of your post, that you just want the
> name definition part of variable declaration, and not the type
> definition part.

It's somewhat ironic that my honest attempt to understand what you meant
by 'variable declaration' --rereading what you wrote several times--
leads to this response, and selective quoting.

> > > I didn't propose anything like that.  The compiler will know that
> > > "initialized" is not local to init_everything because it is not declared
> > > there with a "def".  That has absolutely nothing to do with anything
> > > outside the function init_everything.
> > >
> >
> > Yes you did ;)]
> 
> Did not. (Did too.)  Did not.
> 
> >
> > Most local variables shadowing global names, are intended to be local.
> > Therefore, the only reasonable thing for your 'option explicit' to do,
> > would be to raise an Error with "undefined variable initialized in
> > init_everything".
> 

> That's right.  If you had read my the message you are arguing with, you
> would see that I proposed exactly that, even spelling out the syntax of
> the exception message.
> 

No, you said that it wouldn't raise an error in that case, because,
and I quote:

> > > ... The compiler will know that
> > > "initialized" is not local to init_everything because it is not declared
> > > there with a "def".  That has absolutely nothing to do with anything
> > > outside the function init_everything.


The error you suggested was for an assignment to an undefined variable
at global scope.

If I understand you correctly, you're proposing that an undefined
variable at local scope is assumed to be global scope, and only if
there's no global definition it becomes an error.

I'm saying that that's a bad idea because the missing definition at
local scope would usually be a bug, which would then get hidden because
there happens to be an (unrelated) global definition. You're basically
replacing hard to detect bugs due to missing global statements with
similarly hard to detect bugs due to missing defs.

I was also implying that that's a bad trade-off because 'global' is used
rarely.

Have fun,

Roeland
-- 
r.b.rigilink at chello.nl

"Half of what I say is nonsense. Unfortunately I don't know which half"



More information about the Python-list mailing list