Path: utzoo!attcan!uunet!lll-winken!lll-tis!ames!zodiac!joyce!sri-unix!quintus!ok From: ok@quintus.uucp (Richard A. O'Keefe) Newsgroups: comp.lang.prolog Subject: Re: "clause" in sbprolog? breadth-first evaluation? Message-ID: <163@quintus.UUCP> Date: 8 Jul 88 22:02:58 GMT References: <1630@kalliope.rice.edu> Sender: news@quintus.UUCP Reply-To: ok@quintus.UUCP (Richard A. O'Keefe) Organization: Quintus Computer Systems, Inc. Lines: 30 In article <1630@kalliope.rice.edu> phil@rice.edu (William LeFebvre) writes: >[There is a standard built-in state function clause/2] >Great. Does Stony Brook Prolog have something comparable? I've been >looking and I can't find it. I am trying to write a meta-evaluator for a >specific subset of Prolog programs that does breadth first evaluation >rather than Prolog's depth first. But in order to write it I'm pretty >sure that I need something like "clause". Can anyone help? If you look in the file modlib/src/$assert.P you will see that SB-Prolog's assert* family transforms clauses quite substantially before storing them; clause/2 would have to undo this transformation. At first I meant to remind you of the built-in predicate retract(Clause) which is supposed to pattern match against the entire clause being retracted, then I noticed the fine print in the SB-Prolog manual which says that the SB-Prolog version only matches the Head. (You will also notice near the beginning of the SB-Prolog manual a statement that listing/1 is not yet supplied: it's pretty safe to conclude from that and the behaviour of retract/1 that you might as well stop looking.) I suggest that you would be better off not using clause/2 even in Prologs which have it. The usual Prolog notation is "defaulty", that is, the system only knows that p(X,Y) is a call to a user-defined predicate after it has checked that it isn't something else. You can obtain a much more efficient interpreter (and a more beautiful one) by translating the clauses to an explicit representation. E.g. you might like to turn path(From, To) :- arc(From, Next), path(Next, To). into rule(path(From,To), [arc(From,Next),path(Next,To)]). With a little care, you might be able to push quite a bit of the interpreter's work into the translation.