;;; Module MAIN
(defrule foo ?f <- (foo ?x) => (retract ?f))
(deffacts init (foo 1))
(defmodule MAIN (export ?ALL))
;;; Module BAR
(defmodule BAR (import MAIN ?ALL))
;;; remember that rules are not imported
(defrule bar (foo ?x) => (assert (bar ?x)))
(reset)
(facts)
;;; f-0 (initial-fact)
;;; f-1 (foo 1)
;;; OK
(get-current-module)
;;; MAIN
(watch facts)
(watch rules)
(set-current-module BAR)
(get-current-module)
;;; BAR : OK
;;; until now, everything seems to work as expected
;;; BUT
(run)
;;; gives:
;;; FIRE 1 foo: f-1
;;; <== f-1 (foo 1)
(get-current-module)
;;; BAR
So, it seems that the rule in BAR was not fired, the rule in MAIN was fired, but the current module is still BAR.
From section 10.6 of the manual ("When a run command is given, the agenda of the module that is the current focus is executed"), I expected:
FIRE 1 bar: f-1
==> f-2 (bar 1)
FIRE 2 foo: f-1
<== f-1 (foo 1)
(get-current-module)
MAIN
Notice that I tried this in version 6.3 and 6.4 (last release, 813) and I got the same results.