Subject: [clisp-list] CLOS / compiler bug?

From: "Roland Averkamp" <[email-masked]>
Date: Tue Sep 16 14:22:07 2003

Hello,

I have a problem with the CLOS Implementation and Compiler of clisp-2.31.
I have to files:

File: test-clos-1.lisp

(defgeneric blub (x))
 
File: test-clos-2.lisp

(defclass a () ())
  
(defun bla ()
  (let ((x (make-instance 'a)))
    (pprint "before blub")
    (blub x )
    (pprint "after blub")))

(defmethod blub ((x a))
  (pprint "blub"))

;------------- end -------------

then I do the following at the prompt:

[15]> (progn 
  (unintern 'blub)
  (compile-file "test-clos-1.lisp")
  (load "test-clos-1")
  (compile-file "test-clos-2.lisp")
  (load "test-clos-2")
  (bla))

Datei /home/averkamp/lisp/test-clos-1.lisp wird compiliert...

Wrote file /home/averkamp/lisp/test-clos-1.fas
0 Errors, 0 Warnungen
;; Datei /home/averkamp/lisp/test-clos-1.fas ...
;; Loaded file /home/averkamp/lisp/test-clos-1.fas
Datei /home/averkamp/lisp/test-clos-2.lisp wird compiliert...

Wrote file /home/averkamp/lisp/test-clos-2.fas
0 Errors, 0 Warnungen
;; Datei /home/averkamp/lisp/test-clos-2.fas ...
;; Loaded file /home/averkamp/lisp/test-clos-2.fas
"before blub"
"after blub"

I would have expected:
"before blub"
"blub"
"after blub"

 and this is the result if if the files are not compiled :

16]> (progn
  (unintern 'blub)
  (load "test-clos-1.lisp")
  (load "test-clos-2.lisp")
  (bla))

;; Datei test-clos-1.lisp ...
;; Loaded file test-clos-1.lisp
;; Datei test-clos-2.lisp ...
;; Loaded file test-clos-2.lisp
"before blub"
"blub"
"after blub"

Why is method blub not called in the first example?

If in file test-clos-2.lisp "(defmethod blub ( ..."
 is moved before "(defun bla ...." everything works as expected.

There is no trace of the call to blub in the disassembly of bla:

[35]> (disassemble 'bla)

Disassembly von Funktion BLA
(CONST 0) = A
(CONST 1) = MAKE-INSTANCE
(CONST 2) = "before blub"
(CONST 3) = "after blub"
0 required arguments
0 optional arguments
Kein Rest-Parameter
Keine Keyword-Parameter
9 byte-code instructions:
0     (CONST&PUSH 0)                      ; A
1     (CALL1&PUSH 1)                      ; MAKE-INSTANCE
3     (CONST&PUSH 2)                      ; "before blub"
4     (PUSH-UNBOUND 1)
6     (CALLS1 131)                        ; PPRINT
8     (CONST&PUSH 3)                      ; "after blub"
9     (PUSH-UNBOUND 1)
11    (CALLS1 131)                        ; PPRINT
13    (SKIP&RET 2)
NIL
[36]> 

I do not have this problem with clisp-2.30.

By
Roland

-- 
+++ GMX - die erste Adresse für Mail, Message, More! +++

Getestet von Stiftung Warentest: GMX FreeMail (GUT), GMX ProMail (GUT)
(Heft 9/03 - 23 e-mail-Tarife: 6 gut, 12 befriedigend, 5 ausreichend)

Jetzt selbst kostenlos testen: http://www.gmx.net