Subject: [clisp-list] loading and compiling the Knowledge Machine

From: Joe Corneli <[email-masked]>
Date: Fri Feb 27 03:20:04 2004

I get two problems with Porter and Clark's Knowledge Machine under
CLISP -- problems that, as far as I know, are not experienced by
users of other Common Lisps.

First error: "DEFUN/DEFMACRO(show-stack): #<package ext> is locked".

[1]> (load "~/site-lisp/km/km.lisp")
;; Loading file /Users/arided/site-lisp/km/km.lisp ...
** - Continuable Error
DEFUN/DEFMACRO(show-stack): #<package ext> is locked
If you continue (by typing 'continue'): Ignore the lock and proceed
1. Break [2]> continue
Resetting KM...
      ====================================================
      KM - THE KNOWLEDGE MACHINE - INFERENCE ENGINE v2.0.1
      ====================================================
Copyright (C) 2004 Peter Clark and Bruce Porter. KM comes with ABSOLUTELY
NO WARRANTY. This is free software, and you are welcome to redistribute it
under certain conditions. Type (license) for details.

Documentation at http://www.cs.utexas.edu/users/mfkb/km/
Type (km) for the KM interpreter prompt!
;; Loading of file /Users/arided/site-lisp/km/km.lisp is finished.
t

Second error: "*** - Non-existent directive"

[3]> (compile-file "~/site-lisp/km/km.lisp")

Compiling file /Users/arided/site-lisp/km/km.lisp ...
WARNING in function immediate-classes in lines 5951..6007 :
variable enforce-constraints is used despite of IGNORE declaration.
WARNING in function test-val-constraint in lines 9978..10031 :
Duplicate case label quote :
(case mode ('consistent (km0 `(,val &? (|a| ,@(rest constraint)))))
 ('satisfies (km0 `(,val |is| '(|a| ,@(rest constraint))))))
WARNING in function test-val-constraint in lines 9978..10031 :
Duplicate case label quote :
(case mode
 ('consistent
  (some #'(lambda (possible-value) (km0 `(,val &? ,possible-value)))
   possible-values))
 ('satisfies (member val possible-values :test #'equal)))
WARNING in function test-set-constraint in lines 10033..10060 :
Duplicate case label quote : (case mode ('consistent t) ('satisfies (>= nvals n)))
WARNING in function test-set-constraint in lines 10033..10060 :
Duplicate case label quote : (case mode ('consistent (<= nvals n)) ('satisfies (= nvals n)))
*** - Non-existent directive
Current point in control string:
  ~a~60vT~a
       |
1. Break [4]> :a

These might be related to the version of CLISP that I'm using
(Fink's clisp-2.29-13).  One or both of the errors may be easy to
fix, but I have no idea what to do about them.

Advice would be much appreciated.  The KM code is available under
the GPL from http://www.cs.utexas.edu/users/mfkb/RKF/km.html

---

From: Sam Steingold <[email-masked]>
Date: Fri Feb 27 06:31:06 2004

> * Joe Corneli <[email-masked]> [2004-02-27 05:09:33 -0600]:
>

EXT:SHOW-STACK is a CLISP extension.
when they define a package, they should specify the USE list and no use
the EXT package.
E.g.,

(defpackage "KM" (:use "CL"))
(in-package "KM")

> ('satisfies (= nvals n)))

the above warnings are indicative of sloppy code (at best) ore severe
bugs (at worse)

> Current point in control string:

<http://www.lisp.org/HyperSpec/Body/sec_22-3.html>:
"In place of a prefix parameter to a directive, V (or v) can be used."

CLISP interprets that "v" must be the only prefix argument.
others interpret this more leniently.
please try the appended patch.

-- 
Sam Steingold (http://www.podval.org/~sds) running w2k
<http://www.camera.org> <http://www.iris.org.il> <http://www.memri.org/>
<http://www.mideasttruth.com/> <http://www.honestreporting.com>
Sufficiently advanced stupidity is indistinguishable from malice.

--- format.lisp.~1.23.~	2004-01-21 13:27:29.433240900 -0500
+++ format.lisp	2004-02-27 09:18:16.021572700 -0500
@@ -116,7 +116,7 @@
              (push (if (eql ch #\#) ':ARG-COUNT ':NEXT-ARG)
                    (csd-parm-list newcsd))
              (setf (csd-v-or-#-p newcsd) T)
-             (go param-ok-1))
+             (go param))
             (#\, (push nil (csd-parm-list newcsd)) (go param))
             (#\: (go colon-modifier))
             (#\@ (go atsign-modifier))
@@ -130,7 +130,7 @@
                           (TEXT "~A must introduce a number.")
                           ch))
           (push intparam (csd-parm-list newcsd))
-          (go param-ok-2)
+          (go param-ok)
 
           quote-param           ; Quote-Parameter-Treatment
           (incf index)
@@ -140,10 +140,8 @@
             (go string-ended))
           (setq ch (schar control-string index))
           (push ch (csd-parm-list newcsd))
-
-          param-ok-1            ; Parameter OK
           (incf index)
-          param-ok-2            ; Parameter OK
+          param-ok              ; Parameters OK
           (when (>= index (length control-string))
             (format-error control-string index (errorstring))
             (go string-ended))

---

From: Sam Steingold <[email-masked]>
Date: Fri Feb 27 08:51:05 2004

> Current point in control string:

actually, this is broken.
there must be a comma between prefix arguments "60" and "v".
please report this as a bug to the author of the software.

-- 
Sam Steingold (http://www.podval.org/~sds) running w2k
<http://www.camera.org> <http://www.iris.org.il> <http://www.memri.org/>
<http://www.mideasttruth.com/> <http://www.honestreporting.com>
If you're beeing passed on the right, you're in the wrong lane.

---

From: Joe Corneli <[email-masked]>
Date: Fri Feb 27 10:38:06 2004

I just commented the containing function out & sent that as a patch
-- I will send the comma now. (Apparently some other lisp(s) don't
complain.)

Thanks for your informative help.