[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
typep optimization for CLOS-classes
- To: clisp-list@ma2s2.mathematik.uni-karlsruhe.de
- Subject: typep optimization for CLOS-classes
- From: Matthias Lindner <matthias@intellektik.informatik.th-darmstadt.de>
- Date: Thu, 14 Aug 1997 18:41:52 +0200
- Reply-to: matthias@intellektik.informatik.th-darmstadt.de
Hello,
first I'd like to thank Bruno for his immediate help with my CALL-IN
problem. Everything works fine now! :-)
However, there is another little problem I just discovered. This time
it's a problem with CLISP's built-in CLOS.
Here is an example: The following is the content of the file
cltest.lsp.
;;; -------------------------------------------------------------
;;; File: cltest.lsp
;;; -------------------------------------------------------------
(in-package "USER")
(use-package "CLOS")
(defclass <A> () ())
(defmethod ISA-B ((a <A>))
(typep a '<B>))
(defclass <B> (<A>) ())
;;; ---- END of cltest.lsp --------------------------------------
If I compile this file, there are no problems:
% clisp -c cltest.lsp; clisp -q -i cltest.fas
Compiling file /home/DB/lsp/cltest.lsp ...
Compilation of file /home/DB/lsp/cltest.lsp is finished.
0 errors, 0 warnings
;; Loading file cltest.fas ...
;; Loading of file cltest.fas is finished.
Everything as expected. The problem occurs, if I recompile the file
exit CLISP and try to read the compiled file again:
> (compile-file "cltest.lsp")
Compiling file /home/DB/lsp/cltest.lsp ...
Compilation of file /home/DB/lsp/cltest.lsp is finished.
0 errors, 0 warnings
T
> (bye)
162 [ttyp5] db@orion ~/lsp>> clisp -q -i cltest.fas
;; Loading file cltest.fas ...
*** - FIND-CLASS: <B> does not name a class
1. Break>
Reading the result of the second compilation triggers an error!
I think this problem occurs, as the compiler optimized the expression
(typep a '<B>) to (clos::subclassp (clos:class-of a) (find-class '<B>)).
This is correct - unfortunately the compilation of this expression
causes the insertion of #.(FIND-CLASS '<B>) into the .fas-file
*before* the definition of class <B>.
It's not a big problem as it can be fixed by moving the definition of
class <B> before the definition of method ISA-B, but sometimes it is
annoying to sort class definition like this.
Is the above behavior a bug or a feature of CLISP?
--Matthias
------------------------------------------------------------------------------
Matthias Lindner
Wilhelm-Leuschner-Str.46
64293 Darmstadt
Germany
TEL: +49 6151 22071
NET: matthias@intellektik.informatik.th-darmstadt.de
WWW: http://aida.intellektik.informatik.th-darmstadt.de/~matthias/
------------------------------------------------------------------------------