[Types-sig] Issue: definition of "type"

Greg Stein gstein@lyra.org
Wed, 22 Dec 1999 12:16:33 -0800 (PST)


On Thu, 23 Dec 1999, skaller wrote:
> Greg Stein wrote:
> > > a = [Foo(), Bar()]
> > >
> > > for el in a:
> > >    el.doSomething()
> > >
> > > Doesn't this rely on run-time information? How would a type system deal
> > > with this? I suppose I'm entering the domain of interfaces now...
> > 
> > The type of "a" is a List where the elements' type is the union of the
> > type of each initialization value.
> 
> No. Extra values can be appended of other types. If you want to have
> lists of a particular type, this must be declared as a constraint.

Extra values could be appended, but in the above code, the union
algorithm is sufficient to determine the type of "a".

Later in the code, the list may change type or we may raise errors if some
appends something not part of its type -- I don't care and it doesn't
matter here. We're trying to figure out the type of the list to know
whether the loop will succeed or not.

I also believe that we would ignore the fact that el.doSomething() could
theoretically alter "a".
[ again, a case where Paul's desire for type-safety breaks -- we can't
  know that "a" doesn't get changed during that call. ]

Cheers,
-g

-- 
Greg Stein, http://www.lyra.org/