home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / lang / prolog / 1667 < prev    next >
Encoding:
Internet Message Format  |  1992-09-08  |  1.3 KB

  1. Path: sparky!uunet!munnari.oz.au!goanna!ok
  2. From: ok@goanna.cs.rmit.oz.au (Richard A. O'Keefe)
  3. Newsgroups: comp.lang.prolog
  4. Subject: Re: Compilation of Disjuncts
  5. Message-ID: <14395@goanna.cs.rmit.oz.au>
  6. Date: 8 Sep 92 04:20:34 GMT
  7. References: <1992Sep1.160505.6828@irisa.fr> <MATSC.92Sep2141625@vishnu.sics.se>
  8. Organization: Comp Sci, RMIT, Melbourne, Australia
  9. Lines: 35
  10.  
  11. In article <MATSC.92Sep2141625@vishnu.sics.se>, matsc@sics.se (Mats Carlsson) writes:
  12. >    do you do anything special about this construct, or do you just
  13. >    consider it as an ordinary predicate with a definition like:
  14. >    P ;_Q :- P.
  15. >    _P; Q :- Q.
  16. > SICStus Prolog does nothing special, and considers it as an ordinary
  17. > predicate as you describe.
  18.  
  19. That cannot be so, because SICStus Prolog gets the right answer for this
  20. program:
  21.  
  22.     p :- ( q(1), ! ; q(2) ).
  23.     p :- q(3).
  24.  
  25.     q(X) :- write(X), nl.
  26.  
  27.     ?- p, fail.
  28.  
  29. The right answer is to write 1 and then fail.  If it were done this way:
  30.  
  31.     p :- 'OR'( (q(1),!), q(2) ).
  32.     p :- q(3).
  33.  
  34.     'OR'(P, Q) :- call(P).
  35.     'OR'(P, Q) :- call(Q).
  36.  
  37.     q(X) :- write(X), nl.
  38.  
  39. which _would_ treat ; as an ordinary predicate, then the output would
  40. be 1 2 3.  SICStus Prolog gets this right, so there has to be _something_
  41. special about disjunction.
  42.  
  43. -- 
  44. You can lie with statistics ... but not to a statistician.
  45.