[Types-sig] Type annotations
Paul Prescod
paul@prescod.net
Thu, 16 Dec 1999 05:29:50 -0800
Okay, I see four different approaches to the syntax short-term type
annotation. Personally, I do not think that it is too early to talk
about syntax because we need to communicate these ideas. Here are my
metrics:
Python 1.5 compatibility: Sill the Python 1.5 compiler accept it? Will
it have reasonable semantics?
Logical separation: Will users be able to understand that runtime
objects are not available?
Convenience: How easy is it to edit?
Syntactic Cleanliness: How "obvious" is it what the declaration means?
1. separate file:
Python 1.5 compatibility: high
Logical separation: high
Convenience: low
Syntactic Cleanliness: high
2. labelled string expressions: (like 3, but in strings)
Python 1.5 compatibility: high
Logical separation: high
Convenience: medium
Syntactic Cleanliness: medium
3. in separate decl statements: (Incompatible with Python 1.5, but
easily converted)
Python 1.5 compatibility: low
Logical separation: high
Convenience: medium
Syntactic Cleanliness: high
4. in-line in "other" declarations
Python 1.5 compatibility: low
Logical separation: low
Convenience: high
Syntactic Cleanliness: high
5. in dictionaries, lists, and other basic Python objects, "overloaded"
with special meaning
Python 1.5 compatibility: high
Logical separation: medium
Convenience: high
Syntactic Cleanliness: low
Of course if we use a backwards-incompatible expression syntax then
backwards-incompatibility is not an issue. That is one reason I propose
check_type( expr, type ) which can be interpreted in old Python as a
function call.
My preference is to allow three different syntaxes according to a
schedule:
January: separate files (we need this anyhow to define types for the
builtin modules)
February: in-module string declarations and build separate files
Python 2.0: either 3 or 4
I admit that I don't find the compatibility benefits of 5 to be worth
the obfuscation. Parsing is not THAT hard.
--
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