[Types-sig] Basic questions

Paul Prescod paul@prescod.net
Mon, 20 Dec 1999 11:28:39 -0600


Martijn Faassen wrote:
> 
> Another way to do it is to use interfaces and say Foo and Bar both
> conform to some interface which supports doIt(). This was something we
> wouldn't discuss in this SIG, but can we in fact avoid it?

It seems to me that we've been discussing it for about a week now! You
are right that we can't avoid it.

> * inheritance
> 
> I haven't seen too much discussion on how types are going to interact
> with the inheritance system.

I think it would work more or less as it does in other object oriented
languages. I, personally, am concentrating on the parts of the system
that I feel I don't understand. Those parts mostly have to do with
Python's dynamism and not with its already existing type system. Of
course subtypes of "foo" should follow "foo"'s interface and should be
recognized as "foo"s.

But the much more basic question is whether:

class foo: pass

even *defines* a type that can be used in type declarations. Greg says
yes, even if the declaration is buried in code. Tim says no,(I think) 
not unless it is preceded with a decl statement. I'm trying to figure
out which one is right. We can get to inheritance and interfaces later.

Basic questions. 

1. Is this valid:

class foo: pass

def a( arg: foo ): pass

2. Is this valid:

if someFunc():
	class foo: "abc"
else:
	class foo: "def"

def a( arg: foo ): pass


-- 
 Paul Prescod  - ISOGEN Consulting Engineer speaking for himself
The occasional act of disrespect for the American flag creates but a 
flickering insult to the values of democracy -- unless it provokes 
America into limiting the freedoms that are its hallmark.
           -- Paul Tash, executive editor of the St. Petersburg Times