[m-dev.] diff: type_name/1 et al
fjh at cs.mu.oz.au
Thu Apr 24 14:40:30 AEST 1997
Tyson Richard DOWD, you wrote:
> Just a quick point before reviewing the whole diff...
> > - % num_functors(TypeInfo) returns the number of different functors
> > - % for the type specified by TypeInfo, or -1 if the type is not a
> > - % discriminated union type.
> > + % type_name(Type) returns the name of the specified type.
> > + % (e.g. type_name(type_of([2,3])) = "list(int)").
> > +
> > +:- func type_name(type_info) = string.
> > +
> Hmmm.. shouldn't this be cc_multi? A variable can have more than
> one type name (equivalence types).
Yes, that is a very good point. We need to distinguish
between `type_of', which may return an equivalence type,
and which must be cc_multi, and `canonical_type_of',
which only ever returns a builtin type or a discriminated
union type, because it expands out equivalence types.
Oh, and since type_of must be cc_multi, it can't be a function, instead
it must be a predicate. `canonical_type_of' can be a function, though.
Fergus Henderson <fjh at cs.mu.oz.au> | "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh> | of excellence is a lethal habit"
PGP: finger fjh at 18.104.22.168 | -- the last words of T. S. Garp.
More information about the developers