Menu

#1 Suggesiton for retrieve macro

closed
nobody
None
5
2004-06-07
2004-04-04
No

Hi David -

A suggestion to make the retrieve macro more powerful:
Currently, it is only possible to do queries which retrieve
instances, but not facts or slot values. By replacing
,(find-instance-of var) with ,var we'll be able to retrieve
instances and facts, as well as slot values:

(retrieve2 (?inst) (a (:object ?inst))) ;; different syntax,
but we can still get instances
(retrieve2 (?fact) (?fact ?a)) ;; get fact objects
(retrieve2 (?slotval) (a (s1 ?slotval)) (b (s2 ?slotval))) ;;
get slot values

Here's the code:

(defmacro retrieve2 ((&rest varlist) &body body)
(flet ((make-query-binding (var)
`(cons ',var ,var))) ;; just ,var instead of ,(find-
instance-of var)
(let ((query-name (gensym))
(query (gensym)))
`(with-inference-engine ((make-query-engine
(inference-engine)))
(let* ((,query-name (gensym))
(,query
(defquery ',query-name
(query-fact)
,@body
=>
(push (list ,@(mapcar #'make-query-
binding varlist))
*query-result*))))
(run-query ,query))))))

Aneil
(aneil@hms.harvard.edu)

Discussion

  • David E. Young

    David E. Young - 2004-06-03
    • assigned_to: nobody --> youngde
    • status: open --> open-accepted
     
  • David E. Young

    David E. Young - 2004-06-06

    Logged In: YES
    user_id=21258

    This is an excellent suggestion, and will make the change.

    As an aside, RETRIEVE as implemented is somewhat transient.
    Eventually I would like to add a prolog-style backward
    chaining interpreter to Lisa and use it to implement a more
    powerful query mechanism.

     
  • David E. Young

    David E. Young - 2004-06-06
    • assigned_to: youngde --> nobody
     
  • David E. Young

    David E. Young - 2004-06-07
    • status: open-accepted --> closed
     

Log in to post a comment.