[m-dev.] Re: for review: function def's for single out det mode library predicates

Fergus Henderson fjh at cs.mu.OZ.AU
Mon May 17 13:47:35 AEST 1999

On 30-Apr-1999, Lee Naish <lee at cs.mu.OZ.AU> wrote:
> Ralph Becket <rwab1 at cam.sri.com> writes:
> > > :- func list__det_head(list(T)) = T.
> > >
> > > :- func list__det_tail(list(T)) = list(T).
> I think the default/shorter name for these functions should be the det
> forms.  Either list__head should be det, or use list__hd.

Well, having the default name be det would be more consistent with
functional programming languages, but less consistent with the rest of
the Mercury standard library, which for the most part uses explicit
`det_' prefixes or `_det' suffixes for the det versions (an exception
is the use of `map__lookup' rather than `map__det_search').

As a general principle, for cases like these, I think the "default"
version should normally be semidet.  The reasoning is that if there is
a possibility of calling error/1, then the programmer ought to know
about it.

However, I also think that for cases such as map__lookup which are used
very often, and where the `det_' prefix would usually be just a
distraction, it is reasonable to violate this principle in the
interests of brevity and to avoid unnecessary distractions.

So, following this reasoning, list__head should be semidet,
but the det version could be called list__hd rather than list__det_head
if it is likely to be used sufficiently often to warrant this.
Is that going to be the case?  I don't know, but I suspect that
function probably won't be used very often.

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        |     -- the last words of T. S. Garp.
mercury-developers mailing list
Post messages to:       mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions:          mercury-developers-request at cs.mu.oz.au

More information about the developers mailing list