Lisp HUG Maillist Archive

RE: defrule rhs semantics

Thanks for the clarification.

Cheers, David

-----Original Message-----
From: Jason Trenouth [mailto:jason.trenouth@GlobalGraphics.com]
Sent: Wednesday, March 17, 2004 5:23 AM
To: Young, David
Cc: 'lisp-hug@xanalys.com'
Subject: Re: defrule rhs semantics


>>>>> On Mon, 15 Mar 2004 13:42:50 -0500, "Young, David"
<deyoung@bloodhoundinc.com> said:

    David> Hi. In the KW documentation for defrule, I read that
    David> "(<lisp-expr> <term>*) binds the result or results of calling
<lisp-expr> to
    David> the <term> s with execution of the rule terminating if any
bindings fail (if
    David> no <term> s are given execution will always continue)."
....

If you use the above form:

   ((find-frodo ?hobbit) ?frodo)

Then the result of the call to FIND-FRODO is unified (Prolog style)
with the variable ?frodo. If you have not previously bound ?FRODO to
anything then as an unbound variable it will unify with anything
including NIL.

The doc you quote has says nothing about the NIL case as it is no
different from any other value. The only special case the doc mentions
is:

   ((find-frodo ?hobbit))

This is given nothing to unify with and so always succeeds. This form
is mainly used for side-effects.

If you want to be sure you have found a value then you could say
something like:

   ((find-frodo ?hobbit) ?frodo)
   (test ?frodo)

However, in this kind of example I would have expected that Frodoness
is something that can be determined either declaratively or
heuristically within the LHS.

__Jason


Updated at: 2020-12-10 08:57 UTC