Newsgroups: comp.lang.prolog
Path: cantaloupe.srv.cs.cmu.edu!das-news2.harvard.edu!news2.near.net!news.mathworks.com!udel!gatech!howland.reston.ans.net!news.moneng.mei.com!uwm.edu!msunews!harbinger.cc.monash.edu.au!bunyip.cc.uq.oz.au!munnari.oz.au!cs.mu.OZ.AU!munta.cs.mu.OZ.AU!conway
From: conway@munta.cs.mu.OZ.AU (Thomas Charles CONWAY)
Subject: Re: Nondeterminism
Message-ID: <9434915.311@mulga.cs.mu.OZ.AU>
Sender: news@cs.mu.OZ.AU
Organization: Computer Science, University of Melbourne, Australia
References: <9434021.28025@mulga.cs.mu.OZ.AU> <D0Jt09.KBy@ecrc.de> <9434914.27806@mulga.cs.mu.OZ.AU>
Date: Thu, 15 Dec 1994 04:26:30 GMT
Lines: 28

lee@munta.cs.mu.OZ.AU (Lee Naish) writes:

>Fergus and Tom have pointed out that the statistics for the Mercury
>compiler are somewhat biased towards deterministic code.  Even so, I
>think its reasonable to say that most Prolog code is deterministic and
>yet we do pay (some of) the cost of nondeterminism for deterministic
>code.  Addressing this problem is an important issue in language design
>and implementation.  In Mercury the runtime cost is very small (perhaps
>zero) since there is a separate execution model for deterministic code.
>The main cost in Mercury is that programmers must put declarations in the
>code.  If you are primarily interested in efficiency this is obviously a
>good thing (and there are other arguments for having declarations).
>

The compiler has a determinism inference pass. The reason that we
require declarations, rather than depending on the inference is that
the determinism declarations serve as good documentation. When you
write a predicate, you usually know whether it is meant to have more
than one solution or not, and it is helpful for someone else reading
the code to know.
Of course, if you are only writing your programs for yourself and
they are very small, the benefits of the extra documentation are
lost.

Thomas
-- 
Thomas Conway                                           conway@cs.mu.oz.au
AD DEUM ET VINUM
