Fixed two problems with the unifier machinery.
Wed Jul 19 21:52:34 UTC 2006 mantoniotti
* Fixed two problems with the unifier machinery.
Fixed two problems with the unifier machinery.
The first one had to do with the matching of NIL against SYMBOL and LIST
in several places: essentially, the problem is incongruencies in the
results of COMPUTE-APPLICABLE-METHODS in these cases. I think I caught
most of them: unification of lists and the occur-check were the obvious
places where things went awry.
The second problem had to do with the reader macro #T. The original
code generated an object at read time, which is not such a good idea.
Now the code generates a call to MAKE-TEMPLATE with is evaluated later.
Incidentally, the reader macro function is now called |sharp-T-reader|, in
order to placate Emacs fontification.
Modified Files:
templates-hierarchy.lisp unifier.lisp
hunk ./templates-hierarchy.lisp 224
-(defun |#T-reader| (stream subchar arg)
+#||
+(defun |sharp-T-reader| (stream subchar arg)
hunk ./templates-hierarchy.lisp 232
+||#
+
+
+;;; New version with more 'macro-like' behavior. The previous version
+;;; created an object at read-time, which may cause problems with
+;;; MAKE-LOAD-FORMs, constant-ness etc etc.
+
+(defun |sharp-T-reader| (stream subchar arg)
+ (declare (ignore subchar arg))
+ (let ((spec (read stream t nil t)))
+ (typecase spec
+ (null `(make-template nil ',spec))
+ (cons `(make-template ',(first spec) ',spec))
+ (t `(make-template ',spec ',spec)))
+ ))
hunk ./templates-hierarchy.lisp 250
- (set-dispatch-macro-character #\# #\T #'|#T-reader|))
+ (set-dispatch-macro-character #\# #\T #'|sharp-T-reader|))
hunk ./unifier.lisp 233
+ (declare (ignore env))
hunk ./unifier.lisp 243
-(defmethod unify ((x null) (nt nil-template) &optional (env (make-empty-environment)))
+(defmethod unify ((x null) (y null)
+ &optional (env (make-empty-environment)))
+ env)
+
+
+(defmethod unify ((x null) (nt nil-template)
+ &optional (env (make-empty-environment)))
hunk ./unifier.lisp 253
-(defmethod unify ((nt nil-template) (x null) &optional (env (make-empty-environment)))
+(defmethod unify ((nt nil-template) (x null)
+ &optional (env (make-empty-environment)))
hunk ./unifier.lisp 258
-(defmethod unify ((nt1 nil-template) (nt2 nil-template) &optional (env (make-empty-environment)))
+(defmethod unify ((nt1 nil-template) (nt2 nil-template)
+ &optional (env (make-empty-environment)))
hunk ./unifier.lisp 311
+ (declare (ignore env))
hunk ./unifier.lisp 367
+ (declare (ignore env))
hunk ./unifier.lisp 412
+ (declare (ignore env))
hunk ./unifier.lisp 462
- (declare (ignore array-kwd))
+ (declare (ignore array-kwd type-spec))
hunk ./unifier.lisp 473
+ (declare (ignore env))
hunk ./unifier.lisp 478
-#| Old version with heavy syntax
+#|| Old version with heavy syntax
hunk ./unifier.lisp 500
-|#
+||#
hunk ./unifier.lisp 535
+ (declare (ignore env))
hunk ./unifier.lisp 570
- (unify (subseq a from to) (make-template seq-template-kind `(,seq-template-kind ,@spec))))))
+ (unify (subseq a from to)
+ (make-template seq-template-kind `(,seq-template-kind ,@spec))
+ env))))
hunk ./unifier.lisp 616
-#|
+#||
hunk ./unifier.lisp 631
-|#
+||#
+
hunk ./unifier.lisp 643
+
hunk ./unifier.lisp 648
+
+(defmethod occurs-in-p ((var symbol) (pat null) env)
+ ;; This is needed because of different precedence rules among lisps
+ ;; in COMPUTE-APPLICABLE-METHODS when NIL has to matched against
+ ;; SYMBOL and LIST.
+ [_$_]
+ ;; We know (assume) that VAR is not NIL.
+ nil)
+
+