[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[spr7631] Defining a Macro
Hmm. Good thing I read this list; too bad I've been behind in my mail.
Anyway, I'm the author of Rhet, so I think I can clear all this up.
Rhet defines reader macros for [ and ] (amoung others). So it doesn't
work to just macro expand into that since the parser has to see what's
inside. The read-from-string suggestion would work, of course, but there
are lower level primitives for constructing the terms directly (e.g.
CONS-RHET-FORM), and that's what you really want to do. Look at the
programmer's guide for help on the various functions available (tr 363);
and the definition of the macro DEFRHETPRED (in assert-axioms.lisp)
which probably does more than you want, but you'll possibly be able to
start with that and cut out what you don't need; or at least use it as a
roadmap. <Note that defrhetpred predates cons-rhet-form so you may find
formulating your macro using cons-rhet-form to be even simpler.>
Remember you have the source code for Rhet, so use meta-dot when you
need to find a function. I'll be happy to be of further assistance if
you need it; just email me at firstname.lastname@example.org (I'm not in every
day this month, but I will get back to you as soon as I can).
Note that (cons-rhet-form 'dog 'snoopi) -> [dog snoopi]
or assuming you've defined a type t-dog:
(let ((var (create-rvariable "?mydog" (make-i-type 't-dog))))
(cons-rhet-form 'dog var)) -> [dog ?mydog*T-DOG]
etc; there should be more examples in the manuals. So you may not need
your macro at all in light of cons-rhet-form. You can do
(rassert (cons-rhet-form 'dog 'snoopi)) for instance
to assert [dog snoopi] to the kb.
Apologies for cluttering up these lists with Rhet stuff; I just wanted
everyone to know the matter should be closed :-).