[m-dev.] no tag types
Peter Schachte
pets at cs.mu.OZ.AU
Fri Nov 6 15:51:36 AEDT 1998
On Fri, Nov 06, 1998 at 03:21:16PM +1100, Thomas Charles CONWAY wrote:
>
> Maybe a useful thing would be to make:
> :- type foo = int.
> be equivalent to
> :- type foo ---> foo(int).
This doesn't seem like a good idea to me because:
(1) It looks /much/ too much like
:- type foo == int.
It's already natural and tempting to use `=' for
equivalence types. This would make that mistake more
confusing.
(2) The syntax doesn't naturally suggest that f/1 is a
constructor for type foo.
I think a nicer solution is to put a section in the user manual about
no-tag types so users understand them, and put in the reference manual
a statement that Mercury implementations are required to implement
one-constructor, one-argument types without (additional) tags. This
latter bit is tricky to specify without tying implementors hands, but
since Mercury requires full compile-time type analysis, we're just
requiring the implementation to implement constructions and
deconstructions of this type as casts. Relatively speaking, it's not
a lot to demand.
I can think of much more useful extensions to the type system. For
example, I'd like to be allowed to specify for a type what predicate
to call if a term of that type is used as a goal, possibly with extra
arguments, and what function to call if a term of that type is applied
to some arguments. E.g., Wouldn't it be nice to be able to use a map
or an array as a function? This would also let you use a
Boolean-valued function as a predicate.
--
Peter Schachte | The greater part of our happiness depends on
mailto:pets at cs.mu.OZ.AU | our dispositions and not on our
http://www.cs.mu.oz.au/~pets/ | circumstances.
PGP: finger pets at 128.250.37.3 | -- Martha Washington
More information about the developers
mailing list