Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Lisa or rule syntax

17 views
Skip to first unread message

lisp linux

unread,
Mar 7, 2008, 2:18:56 AM3/7/08
to
Hi

I am trying to learn how to do an 'or' rule in Lisa

The following fails to parse unless i remove rule r3
Lisa version used is the latest release 3.21
I get parse error in both clisp2.43 and sbcl 1.0.13
What am I doing wrong ?
I am basically having a hard time doing 'or' rules that have variables for slots.
But in the example below I can't get even fixed slot values to parse right.

;--start code
(eval-when (:compile-toplevel :load-toplevel :execute)
(when (not (find-package "LISA-TEST"))
(defpackage "LISA-TEST"
(:use "LISA-LISP"))))

(in-package "LISA-TEST")

(deftemplate t1 () (slot s))
(deftemplate t2 () (slot s))
(deftemplate t3 () (slot s))

(deffacts testfacts ()
(t1 (s s1))
(t2 (s s2))
(t3 (s s3))
(t1 (s x1)))

(defrule r1 ()
(t1 (s ?s1))
=>
(format t "from rule r1 - we got ~A. ~%" ?s1))


(defrule r2 ()
(or (t1 )
(t2 ))
=>
(format t "from rule r2 . ~%"))

(defrule r3 ()
(or (t1 (s s1))
(t2 (s s2)))
=>
(format t "from rule r3 . ~%"))

(eval-when (:compile-toplevel :load-toplevel :execute)
(format t "doing stuff ~%")
(reset)
(run))

;;-end code


-Antony

Andrew Philpot

unread,
Mar 7, 2008, 1:35:47 PM3/7/08
to
On 2008-03-07, lisp linux <gmai...@lisp.linux> wrote:
> Hi
>
[snip]

> (defrule r3 ()
> (or (t1 (s s1))
> (t2 (s s2)))
> =>
> (format t "from rule r3 . ~%"))
[snip]

This syntax did work on lisa 2.4, and I also see that it now (3.2)
generates a parse error:

Error: Rule parsing error: rule name R3, pattern location 0 (malformed slot)
[condition type: RULE-PARSING-ERROR]

Since by Lisa's semantics of OR this is supposed to expand into two
rules, you could always just code them yourself:

(defrule r3-1 ()
(t1 (s s1)
=>
(format t "from rule r3 . ~%")))

(defrule r3-2 ()
(t2 (s s2)


=>
(format t "from rule r3 . ~%"))

--
Andrew Philpot
USC Information Sciences Institute
phi...@isi.edu

lisp linux

unread,
Mar 8, 2008, 12:45:43 AM3/8/08
to
Andrew Philpot wrote:
> On 2008-03-07, lisp linux <gmai...@lisp.linux> wrote:
>> Hi
>>
> [snip]
>> (defrule r3 ()
>> (or (t1 (s s1))
>> (t2 (s s2)))
>> =>
>> (format t "from rule r3 . ~%"))
> [snip]
>
> This syntax did work on lisa 2.4, and I also see that it now (3.2)
> generates a parse error:
>
> Error: Rule parsing error: rule name R3, pattern location 0 (malformed slot)
> [condition type: RULE-PARSING-ERROR]
Thank you for verifying.

>
> Since by Lisa's semantics of OR this is supposed to expand into two
> rules, you could always just code them yourself:
>
> (defrule r3-1 ()
> (t1 (s s1)
> =>
> (format t "from rule r3 . ~%")))
>
> (defrule r3-2 ()
> (t2 (s s2)
> =>
> (format t "from rule r3 . ~%"))
>

Yes. This was just a stripped down test case to show the problem i ran into.
It would not be much fun if I have to figure out what high level stuff is buggy and translate them
to low level primitives by hand.
Anyone else uses Lisa ? I can't believe something basic like this can be broken and not noticed.

-Antony

0 new messages