Path: utzoo!utgpu!watserv1!watmath!att!pacbell!pacbell.com!mips!swrinde!zaphod.mps.ohio-state.edu!samsung!cs.utexas.edu!bradley From: bradley@cs.utexas.edu (Bradley L. Richards) Newsgroups: comp.lang.prolog Subject: Re: Meta-programming question Message-ID: <12064@cs.utexas.edu> Date: 31 Aug 90 16:24:40 GMT References: <199@qt.cs.utexas.edu> <3646@goanna.cs.rmit.oz.au> Organization: U. Texas CS Dept., Austin, Texas Lines: 48 First, many thanks to all the folks who responded to my question! >ok@goanna.cs.rmit.oz.au (Richard A. O'Keefe) writes: >Sigh. This is why we wanted a Prolog standard... > >It isn't perfectly clear what you don't want bound. If you are probing >for a clause with a pattern, and you are happy for that pattern to get >instantiated, but you want (a copy of) the original clause, do > > head_clause_nobind(Head, Clause) :- > clause(Head, _, Ref), > instance(Ref, Clause). Indeed this is exactly what I want to do. And I'm in strong agreement with your first comment, because Arity *does not* support the clause/3 predicate. I attempted to write one using recorded/3 when I found that it can in fact access clauses--but, sadly, it doesn't do so in a consistent manner. So, it looks like I'm stuck with the effective but slow version > head_nobind_clause_nobind(Head, Clause) :- > functor(Head, F, N), > functor(Skel, F, N), > clause(Skel, Body), > \+ \+ Skel = Head, > make_clause(Skel, Body, Clause). >May I respectfully suggest that trying to use the "raw" clause store >is almost always a bad idea? Suppose you are doing your meta-programming >and start tinkering with the append/3 predicate. What if your meta-program >uses append/3? You want to keep the levels separate. Indeed you are right. I've been away from Prolog for a while so I'm not sure if this is "standard," but Arity provides the option of creating different "code worlds," and I keep the meta-programming stuff isolated this way. This has the advantage that when I want to execute a predicate in the object program, I can merely change worlds and call the appropriate predicate. Presuming it doesn't go off in never-never land, and that I don't want any intermediate results, this is faster than running a metainterpreter. Thanks again! Bradley --------------------------------------------------------------------------- Bradley L. Richards uucp: cs.utexas.edu!bradley bradley@cs.utexas.edu CompuServe: 75216,1744 ---------------------------------------------------------------------------