Re: Prolog goals order
- From: bart demoen <bmd@xxxxxxxxxxxxxx>
- Date: Fri, 25 Aug 2006 22:22:59 +0200
On Thu, 24 Aug 2006 15:58:49 -0700, Greg Buchholz wrote:
Mauro DiNuzzo wrote:
As an example, the goal:
?- X+1>10, read(X).
raises an instantiation error. (we have the mind full of examples like
this!)
My question is: "why Prolog does not change itself to overcome this
problem?".
FWIW, I think the Mercury langauge does exactly that. From
http://doc.rz.ifi.lmu.de/programming/mercury/transition_guide.html
"the Mercury compiler automatically reorders conjunctions so that all
consumers of a variable come after the producer"
The Mercury compiler reorders goals in a conjunction statically and
within a clause. That's cool, but it is also quite limited.
It relies on your declarations (or what it can infer from your
declarations+program). Dynamic reordering and reordering beyond the
clause scope is what one would really want - or what I guess Mauro would
like. It is possible, but as Jan has pointed out, it comes at a
performance price (especially when you don't need it). There is another
cost: if two (or more) goals are ready to execute at the same time, you
(as a programmer) usually have no control over the order in which they are
executed. This means you might lose control over the complexity of your
program. For programmers, that's unacceptable. For a specification, that
is fine. Maybe some time in the future, computer science bridges the gap
between programming and specifying. Until then, entre les deux notre coeur
se balance: try a bit of Prolog, try a bit of Answer Set Programming. And
tell us about your experience.
Cheers
Bart Demoen
.
- References:
- Prolog goals order
- From: Mauro DiNuzzo
- Re: Prolog goals order
- From: Greg Buchholz
- Prolog goals order
- Prev by Date: Ebay Item: Art of Prolog Sterling and Shapiro 2nd Edition VGC
- Next by Date: Re: Prolog goals order
- Previous by thread: Re: Prolog goals order
- Next by thread: Re: Prolog goals order
- Index(es):
Relevant Pages
|