home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / lang / prolog / 1666 < prev    next >
Encoding:
Internet Message Format  |  1992-09-08  |  1.2 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: <14393@goanna.cs.rmit.oz.au>
  6. Date: 8 Sep 92 04:15:13 GMT
  7. References: <1992Sep1.160505.6828@irisa.fr>
  8. Organization: Comp Sci, RMIT, Melbourne, Australia
  9. Lines: 23
  10.  
  11. In article <1992Sep1.160505.6828@irisa.fr>, serge@irisa.fr (Serge Lehuitouze) writes:
  12. > You, WAM gurus, 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.  
  17. There is a third possibility:  when a clause contains a goal of the form
  18. (P ; Q), e.g. H :- A, (P ; Q), B
  19. split that goal out as a separate predicate:
  20.     T(Xs) :- P.
  21.     T(Xs) :- Q.
  22.     H :- A, T(Xs), B.
  23. where Xs is vars([P,Q]) intersect vars([H,A,B]).
  24.  
  25. But yes, disjunction is usually compiled specially, for two important
  26. reasons:
  27.     1.  It would be unreasonably slow and inefficient to do otherwise.
  28.     2.  Disjunction and if->then;else are transparent to cuts, that is,
  29.     a cut inside one of them has effect on the whole predicate,
  30.     not just the disjunction or if->then;else.
  31.  
  32. -- 
  33. You can lie with statistics ... but not to a statistician.
  34.