[Types-sig] Basic questions

Greg Stein gstein@lyra.org
Tue, 21 Dec 1999 12:17:09 -0800 (PST)


On Mon, 20 Dec 1999, Paul Prescod wrote:
>...
> 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) 

Definitely yes. The typedecl syntax allows the use of a class object as a
way to specify a typedecl. Internally, the class contains a reference to
an interface definition; the interface is the "real" typedecl.

>...
> 1. Is this valid:
> 
> class foo: pass
> 
> def a( arg: foo ): pass

Absolutely. The compiler understands that "foo" refers to a class object,
so it is allowed in a typedecl.

> 2. Is this valid:
> 
> if someFunc():
> 	class foo: "abc"
> else:
> 	class foo: "def"
> 
> def a( arg: foo ): pass

Absolutely. The compiler understands that "foo" refers to a class object,
although it doesn't know which one. No matter, though, as it just
associates a union typedecl with the name "foo".

Cheers,
-g

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