[Types-sig] Proposed Goals PEP

Marcin 'Qrczak' Kowalczyk qrczak@knm.org.pl
13 Mar 2001 20:25:56 GMT


Tue, 13 Mar 2001 11:42:51 -0800, Paul Prescod <paulp@ActiveState.com> pis=
ze:

> And how does a list of tuples of a list of tuples work? I have to
> generate strongly typed objects at every level?

Neel Krishnaswami proposed essentially the same concept as me, so I
will defend the concept.

Among these types only lists need to store the type of items (a single
object for the whole list). A dict stores two types.

A tuple has a fixed shape (length and types of elements). Since
it's immutable, it does not store the shape explicitly. The shape
is conceptually derived from the tuple's contents. We don't need to
extend the representation of tuple to let it be typed, only define
how to typecheck a tuple.

A type constraint which defines a tuple shape, applied to a tuple
object, just pushes declared types of items to actual items, after
checking that the length matches.

If we feel the need, we may define a more flexible ways to describe
tuple shapes, e.g. allowing unspecified number of items of a specified
type. But I'm not doing that. This may only be considered after the
type system is ready and working, and we are happy with its basics
but want this flexibility.

> maybe StringSequence is such a common case that we should have a
> special type for it.

No, there will be no such special cases at all.

--=20
 __("<  Marcin Kowalczyk * qrczak@knm.org.pl http://qrczak.ids.net.pl/
 \__/
  ^^                      SYGNATURA ZAST=CAPCZA
QRCZAK