[Types-sig] Module Attribute visibility

Greg Stein gstein@lyra.org
Fri, 17 Dec 1999 00:37:26 -0800 (PST)


On Thu, 16 Dec 1999, Paul Prescod wrote:
> Greg Stein wrote:
> > IMO, let's solve static type checking. Leave visibility and modification
> > rules to another phase. They are orthogonal problems, and we would do well
> > to reduce our problem set (and the amount of discussion thereby
> > engendered (my 25 cent word for the day :-)).
> 
> They are not orthogonal at all. I can't statically check a file that
> uses sys.version unless I know that sys.version has not been overwritten
> with a string. We can't allow the runtime system to violate the
> expectations of the static type engine. We also don't want every user of
> sys.version to need to assert its type.

You certainly can statically check a file. Assume that sys.version is a
string and remains a string. Done.

Why can't the runtime system violate the expectations? Seriously: I doubt
you can prevent it. Python is simply too dynamic. I'd be surprised if you
could completely stop me from changing sys.version if I want really trying
to do so.

This falls back to what Tim was stating: you can output code that assumes
a particular type and runs better, but falls back to a slower version if
the type is wrong (or maybe raises an error). I certainly would hope that
the compiler/PVM will not bomb because somebody managed to change the type
of something where the type check system didn't think it would be changed.

I think the type check system will work to signal errors at compile time,
but I don't think it needs to go very far past that (e.g. hard-line
restrictions on modification). This is basically a corollary of "we're all
adults here." i.e. don't be a child and put a list into sys.version :-)

Cheers,
-g

-- 
Greg Stein, http://www.lyra.org/