[Types-sig] const (was: PyDL RFC 0.02)

skaller skaller@maxtal.com.au
Fri, 31 Dec 1999 05:41:03 +1100


Paul Prescod wrote:
 
> I don't follow you and anyhow I don't see why banning some name
> rebindings needs to be high on our list of things to do. The
> optimization and safety benefits are not as high as those of ordinary
> type checking.

	I do not agree. One of the most sought after optimisations
in Python is caching. Preventing rebindings in loaded modules
and/or defined classes permits function and method caching.
It may be the benefits are not as great in total as typing
would bring, but they are certainly significant, and they're
very high on our priorty list becase the changes required
to enforce such a rule are trivial (a one line change
in Viper now prints a warning message for the module case).
The change is also trivial to document and specify.

	I contend there is a very large benefit for a very small
effort here. A proposal is likely to be accepted, Guido has
been heard to murmur in favour of it :-) And, it is likely to
make it into Python 1.6, even if the more ambitious typing proposal
produced does not. This should win Brownie points for the Sig. :-)
 
> Yes and no. We are now able to associate types with names so we need to
> be cognizant of both the type of the name and the type of the object.

	precisely, yes, I agree, except i do not agree that names
have types associated with them. They have _interfaces_ associated
with them. Objects have _types_ associated with them.
That is, actual TypeType objects.

	Example of difference: a module has a type. All modules
have the _same_ type. Most modules have _different_ interfaces.
An interface declaration not only asserts that a name is associated
with an object of module type at run time, but also that the module
have certain attributes of certain types.
 
> My point was that we need to treat modules differently than classes
> because two modules cannot export the same interface whereas two classes
> can.

	Why cannot two modules can export the same interface?
The _names_ of the interfaces may differ.

> There is no equivalent code for modules because module interfaces are
> not named and modules do not claim to conform to particular interfaces.

	Why not? I think they do. They are named.
The name is encoded in the interface file name (.pi file).
 
-- 
John Skaller, mailto:skaller@maxtal.com.au
10/1 Toxteth Rd Glebe NSW 2037 Australia
homepage: http://www.maxtal.com.au/~skaller
voice: 61-2-9660-0850