[Types-sig] typedefs (was: New syntax?)

Martijn Faassen m.faassen@vet.uu.nl
Mon, 20 Dec 1999 16:44:18 +0100

Greg Stein wrote:
> On Fri, 17 Dec 1999, Martijn Faassen wrote:
> > typedef Footype(int, int):
> >     return int
> >
> > var handlermap = {string: Footype}
> I see typedefs as a way to associate a typedecl with a name. In your
> example here, I'm not sure how to do a typedef of something like
> List<String>. You seem to have pegged typedef to only do function
> typedefs.

And class typedefs, I suppose, but you're right. Though you could do

typedef Footype: List(Int)
I should finally work out my syntax proposal into something sensible
because now I'm confusing myself. :) I do still think there's something
interesting to be learned from the 'class instantiation' - 'typedef
instantiation' and 'value assignment' - 'type assignment' analogy.

> In any case, I think using "def" inline to define a function typedecl is
> fine. A typedef is merely used to create an alias, to clarify a later
> declaration.

Yes, but you basically have the same setup with current Python if you
exclude Lambdas. A function definition is merely used to create an
'alias' for a piece of code, to clarify other pieces of code. If you
assume for the moment lambdas are bad, we may want to assume by analogy
that inline defs are not a good idea either.