[Types-sig] List of FOO

Guido van Rossum guido@CNRI.Reston.VA.US
Tue, 14 Dec 1999 11:49:50 -0500


> From: Paul Prescod <paul@prescod.net>

> > > #2. The first version of the system will not allow the use of types
> > > that cannot be referred to as simple Python objects. In particular it
> > > will not allow users to refer to things like "List of Integers" and
> > > "Functions taking Integers as arguments and returning strings."
> > 
> > It's been said before: that's a shame.  Type inference is seriously
> > hindered if it doesn't have such information.  (Consider a loop over
> > sys.argv; I want the checker to be able to assume that the items are
> > strings.)
> 
> It took two years to get the parameterized version of the Java type
> system up and running.

Probably because Java was initially conceived as a language with a
"classic" type system (like C or Pascal).  Python on the other hand
already has all this.

> Let me ask this your opinion on this question
> (seriously, not sarcastically), should we include a spelling for "list
> of string" and not "callable taking list of callables taking strings
> returning integers returning string" and what about "callable taking
> list of callables taking <T> and R returning list of callables taking
> <R> and returning <T>." You see my problem? I could special case "list
> of" as Java and C did if we agreed to take our chances that my syntax
> would be extensible. We could even steal that weird "[]" thing that C
> and Java do:
> 
> 	StringType [] foo

If we could express all those the type checker could do a much better
job.  If we could at least do the ones without the <T> notation, we'd
still be doing a good job.  Stopping at "list" is useless.

(I'm guessing your use of "R" instead of "<R>" once is a typo and not
something deep I've missed?)

--Guido van Rossum (home page: http://www.python.org/~guido/)