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

  1. From: jensk@hpbbrd.bbn.hp.com (Jens Kilian)
  2. Date: Mon, 7 Sep 1992 10:39:12 GMT
  3. Subject: Re: Compilation of Disjuncts
  4. Message-ID: <97440012@hpbbrd.bbn.hp.com>
  5. Organization: HP Mechanical Design Division
  6. Path: sparky!uunet!wupost!usc!sdd.hp.com!scd.hp.com!hplextra!hpfcso!hpfcmdd!hpbbrd!jensk
  7. Newsgroups: comp.lang.prolog
  8. References: <1992Sep1.160505.6828@irisa.fr>
  9. Lines: 37
  10.  
  11. > >The main reason for compiling disjunctions is that it can speed up code
  12. > >like
  13. > >
  14. > >    p(X) :-
  15. > >      (  X >= 0 ->
  16. > >         do_something_for_positive_X(X)
  17. > >      ;  do_something_for_negative_X(X)
  18. > >      ).
  19. > >
  20. > No. The main reason for compiling disjunctions is to avoid to build a structure
  21. > and metacall it. The improvement you mention is also significant, but nowhere as important as this.
  22. > --Micha
  23.  
  24. I was thinking about the alternative approach of compiling a disjunction
  25. to a call of an auxiliary predicate:
  26.  
  27. P :- Q; R.       ==>    P :- dummy(...).
  28.  
  29.             dummy(...) :- Q.
  30.             dummy(...) :- R.
  31.  
  32. where in place of ... you have to insert the variables occuring in Q and R, as
  33. well as any information needed for handling cuts.
  34.  
  35.     Sorry about the confusion,
  36.  
  37.     Jens.
  38. --
  39. Internet: jensk@hpbeo82.bbn.hp.com    HPDESK : JENS_KILIAN%XU@HP1200
  40. MausNet:  Jens Kilian @ BB                     KILIAN_JENS/HP1200_XU@hpbbi4
  41. Phone: (0|+49)7031-14-4308            TELNET : 778-4308
  42. Fax  : (0|+49)7031-14-2049
  43. -------------------------------------------------------------------------------
  44. As the air to a bird, or the sea to a fish, so is contempt to the contemptible.
  45.  
  46.