nikodemus / esrap

OLD REPOSITORY: Please go to:
https://github.com/scymtym/esrap
81 stars 25 forks source link

Allow to detect which element is matched inside OR #19

Closed alexey-martynov closed 11 years ago

alexey-martynov commented 11 years ago

We have dynamically generated contents of OR rule. For proper functioning we need to know inside :DESTRUCTURE what symbol inside OR is matched.

scymtym commented 11 years ago

Is the following solution feasible for you?

(defrule alternative-1 
  ...
  (:destructure (...)
    (list 1 ACTUAL-RESULT)))

(defrule alternative-2 
  ...
  (:destructure (...)
    (list 2 ACTUAL-RESULT)))

(defrule dynamically-generated
  (or alternative-1 alternative-2 ...)
  (:destructure (alternative &rest result)
    (case alternative
      (1 ...)
      (2 ...)
      ...)))
alexey-martynov commented 11 years ago

No, it can't solve my problem because contents of the OR statement are updated at runtime and contents of the added rules are came from client part. I don't like an idea to parse supplied contents and update them.

Also, problem was introduced by the way of interpretation of the rule symbol if DEFRULE. I can't supply dynamically generated symbol as rule symbol because it simply inserted to the statement.

alexey-martynov commented 11 years ago

:AROUND rule has solved my problem.