[Types-sig] Module Attribute visibility

Paul Prescod paul@prescod.net
Thu, 16 Dec 1999 10:28:13 -0800


Tim Peters wrote:
> 
> Resist the dubious temptation to conflate declaration with initialization,
> and "an easy mechanical transformation to valid Python 1.5.x" consists of
> commenting out the decl stmts!  Heck, call the keyword "#\s+decl\s+" and
> it's a nop.

Okay, but doesn't Python already conflate declaration with
initialization? When I refer to mymod.foo I am referring to an object
that was assigned, somewhere to the name foo in the module mymod.

Are we going to say that statically type checked code can only refer to
declared (not merely assigned) variables in other modules? Would it be
safe to say that undeclared variables are simply not available for type
checking?

Would you suggest that this is even the case for functions? I.e. 

def foo( str ): return str*2

is invisible to the type checker until we add:

decl foo: str -> str

Or would foo have an implicit declaration:

decl foo: PyObject -> PyObject

And if that foo has an implicit declaration, shouldn't this foo also:

foo = lambda x: x*2

-- 
 Paul Prescod  - ISOGEN Consulting Engineer speaking for himself
Three things never trust in: That's the vendor's final bill
The promises your boss makes, and the customer's good will 
http://www.geezjan.org/humor/computers/threes.html