🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.prolog
Article #3358

Re: :- deterministic (HP Prolog)

#3358
From: Bjorn Danielsson
Date: Thu, 12 May 1988 16:59
34 lines
1941 bytes
Gary Fritz is right: The deterministic declaration has the same effect as
inserting a cut at the end of each clause, or the same effect as wrapping
'PROVE-ONCE' around every call to such a predicate. The main reason for
this is to help the compiler produce better LISP code when block-compiling
a Prolog program.

In particular, a conjunction of goals that have been declared deterministic
can be compiled to something like:

	(and (pred1)
	     (pred2)
	     (pred3)
	     (funcall cont))

instead of the general case, where an explicit success continuation is needed
as an extra argument to all three predicates:

	(pred1 #'(lambda ()
		   (pred2 #'(lambda ()
			      (pred3 cont)))))

Also, deterministic-declarations can be (mis-)used in the same way as cut.
In some situations it is easier just to say "only the first solution to this
predicate is ever needed" rather than inserting cuts at the right places.

Today I consider the deterministic-declaration to be useful only as a "pragma"
for the compiler. As a programming device it is less precise than cut, and it
hardly gives any advantage in a WAM implementation. I think a convenient
"cases" or "cond" macro based on a backtrackable if-then-else is a better
way to make programs deterministic, since that's often what people *mean*
when they misuse cut.

-- 
Bjorn Danielsson, ZYX Sweden AB, +46 (8) 665 32 05, bd@zyx.SE
Technical Details
Message-ID: <2525@zyx.SE>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!husc6!bloom-beacon!mit-eddie!bbn!uwmcsd1!ig!agate!ucbvax!decwrl!sun!pitstop!sundc!seismo!uunet!mcvax!enea!zyx!bd
References: <900@cresswell.quintus.UUCP> <6960006@hpfclp.SDE.HP.COM>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!husc6!bloom-beacon!mit-eddie!bbn!uwmcsd1!ig!agate!ucbvax!decwrl!sun!pitstop!sundc!seismo!uunet!mcvax!enea!zyx!bd
From: bd@zyx.SE (Bjorn Danielsson)
Newsgroups: comp.lang.prolog
Subject: Re: :- deterministic (HP Prolog)
Message-ID: <2525@zyx.SE>
Date: 12 May 88 16:59:54 GMT
References: <900@cresswell.quintus.UUCP> <6960006@hpfclp.SDE.HP.COM>
Reply-To: bd@zyx.SE (Bjorn Danielsson)
Organization: ZYX Sweden AB, Stockholm, Sweden
Lines: 34