[Python-3000] Use cases for type annotations? (WAS: Type parameterization)
Guido van Rossum
guido at python.org
Sat May 20 21:52:14 CEST 2006
On 5/20/06, Steven Bethard <steven.bethard at gmail.com> wrote:
> On 5/20/06, Guido van Rossum <guido at python.org> wrote:
> > I've already addressed Steve's other issues. The blogs have the use cases etc.
>
> I'm sorry, I guess I'm just dense, but here's the blogs I've read:
>
> http://www.artima.com/weblogs/viewpost.jsp?thread=85551
> http://www.artima.com/weblogs/viewpost.jsp?thread=86641
> http://www.artima.com/weblogs/viewpost.jsp?thread=87182
> http://www.artima.com/weblogs/viewpost.jsp?thread=89161
> http://www.artima.com/weblogs/viewpost.jsp?thread=101605
> http://www.artima.com/weblogs/viewpost.jsp?thread=92662
> http://www.artima.com/weblogs/viewpost.jsp?thread=155123
>
> And the only use-cases I could extract are:
>
> * optional type checking. Lots of thoughts here, and it seemed like
> most of the blogs were leaning towards introducing interfaces to avoid
> requiring concrete types. But the discussion here has been using
> things like 'int' and 'str', so I'm confused as to whether or not this
> is still the intention.
This was mostly retracted later.
Re-read this one:
http://www.artima.com/weblogs/viewpost.jsp?thread=86641 especially the
section on Motivation.
> * function overloading[1]. I think Philip J. Eby had some interesting
> thoughts here, but in all the prototypes, dispatching was done on
> concrete types. Is there a way to do function overloading that
> doesn't rule-out duck typing and is still reasonably efficient?
You may have read my prototypes, which dispatch on concrete types.
Phillip lets you dispatch on predicates like hasattr(x, 'append').
> I guess, in general, my concerns about the use-cases I found were that:
>
> (1) there were very few real implementations of the ideas, and
Collin Winters is pretty real, and I believe one other person (Tony
Lownds?) has another.
> (2) where there was an implementation, it relied on concrete types
Collin's doesn't. (He rewrote his tutorial to remove this.)
> Is it the intention that type annotations be used primarily to check
> concrete types?
To the contrary, that would be a big mistake.
> Or maybe interfaces are being introduced so that type
> annotations can check them instead? If so, I'd like to see one of the
> prototype systems using interfaces. Or maybe there's some other way
> that type annotations are going to be used that doesn't rely on
> concrete types that I've just missed?
>
> Sorry to still not be getting it!
You could build your own system using interfaces, perhaps by combining
Zope/Twisted interfaces with Collin's implementation?
--
--Guido van Rossum (home page: http://www.python.org/~guido/)
More information about the Python-3000
mailing list