What If..... Strong Types
pyth at devel.trillke.net
Sun Jun 16 12:23:29 CEST 2002
> What if Python had been built from the start with strong types? And I mean
> strong types, not strong typing. The distinction I am trying to draw is that
> variables would not be typed, but that all types would have rigid interfaces.
your wording doesn't really make sense to me. There is no such thing as "variables"
in python. EVERYWHERE in modules, classes, instances, globals(), locals() ...
there are only
Objects *have* strong types (or strong typing if you like). The difference
to e.g. Java is that python does DYNAMIC typing instead of java's STATIC
typing. This is the main hinderance for doing certain optimizations
on compilation time. See the types-SIG for further and very interesting
> Primarily, what if classes always had rigidly defined interfaces. I mean
> that public members had to be declared to exist, and that methods couldn't be
> modified on an instance. Private members could exist but would be really private.
OK. There is lots of discussion about 'interface' concepts. Today interfaces
only exist implicitely in python. There have been lots of efforts to
introduce interface concepts like the one for Zope2/Zope3's components:
http://www.zope.org/Members/jim/PythonInterfaces/Interface (maybe outdated)
I think there is a reason, though, why there is no great rush to introduce
any current interface concept to python. None of the current proposals have
really convinced a large enough portion of python developers to become part of
the core language. I am sure that when python gets explicit interfaces
it's going to be a great thing (tm). But IMO one of the main questions is
how do you mix the declarative nature of interfaces with pythons
powerful dynamic object and namespace model?
My personal fantasies focus on connecting IDL-specified interfaces
(OMG's *I*nterface *D*efinition *L*anguage which is used in many domains)
with python namespaces. Something basically like:
mymodule.py # a python module
mymodule.idl # interface definitions
python's compiler would use *both* files to make sure that they match.
For a to-be-discussed definition of 'match' :-)
More information about the Python-list