Missing something or Bug in CMU CL Compiler with CLOS shared slots? 
Author Message
 Missing something or Bug in CMU CL Compiler with CLOS shared slots?

Hi!

I'm currently having some problems getting the following piece of code
to work:  Either I'm missing something WRT the interactions of
compilation and CLOS shared slots (:allocation :class), or there is a
bug in the CMU Compiler and/or it's CLOS implementation (PCL).

The following code works as espected if run interpreted in CMU CL
(Versions 17f, 18a+ on Linux/Intel and Version 18a on Alpha/DU4.0),
and when run compiled under ACL (Version 4.3 under Linux/Intel), but
produces the following result when run compiled (via compile-file or
compile 'pm-demo, irregardless of optimization settings) und CMU CL
(above versions):

--SNIP--------------------------------------------------------------------

* (pm-demo)
Instance-Hash is #<EQUAL hash table, 0 entries {9180125}> for init-instance of Demo 1 with (:NAME
                                                                                              "Demo 1").
Instance-Hash is #<EQUAL hash table, 0 entries {9181325}> for init-instance of Demo 2 with (:NAME
                                                                                            "Demo 2").
Instance-Hash is #<EQUAL hash table, 0 entries {9182375}> for init-instance of Demo 3 with (:NAME
                                                                                            "Demo 3").
Instance-Hash is #<EQUAL hash table, 0 entries {9183375}> for init-instance of Demo 4 with (:NAME
                                                                                            "Demo 4").
Instance-Hash is #<EQUAL hash table, 0 entries {9184375}> for init-instance of Demo 5 with (:NAME
                                                                                            "Demo 5").
NIL

--SNIP--------------------------------------------------------------------

Unexpectedly -- at least for me -- the id of the hash-table in slot
instance-hash changes with each make-instance, i.e. it seems it is
re-initialized each time.  Here I would have expected something like
this (interpreted), which is what ACL produces, too:

--SNIP--------------------------------------------------------------------

* (pm-demo)
Instance-Hash is #<EQUAL hash table, 0 entries {9022525}> for init-instance of Demo 1 with (:NAME
                                                                                              "Demo 1").
Instance-Hash is #<EQUAL hash table, 1 entry {9022525}> for init-instance of Demo 2 with (:NAME
                                                                                          "Demo 2").
Instance-Hash is #<EQUAL hash table, 2 entries {9022525}> for init-instance of Demo 3 with (:NAME
                                                                                            "Demo 3").
Instance-Hash is #<EQUAL hash table, 3 entries {9022525}> for init-instance of Demo 4 with (:NAME
                                                                                            "Demo 4").
Instance-Hash is #<EQUAL hash table, 4 entries {9022525}> for init-instance of Demo 5 with (:NAME
                                                                                            "Demo 5").
NIL

--SNIP--------------------------------------------------------------------

This is the source-file:

--SNIP--------------------------------------------------------------------

;;; Ein benanntes Objekt
(defclass Subjekt ()
  ((id :reader Objekt-Id :initform (gensym)
       :documentation "Unique Id des Objektes.")
   (name :reader Subjekt-Name :initarg :name)
   (instance-hash :allocation :class
                  :initform (make-hash-table :test #'equal)
                  :documentation "Hash-table aller Instanzen.")))

(defmethod print-object ((obj Subjekt) stream)
  "print-object Methode fuer Simulationssubjekte"
  (print-unreadable-object (obj stream :type t :identity t)
                           (format stream "ID:~A Name:~S" (Objekt-Id obj)
                                   (Subjekt-Name obj))))

(defmethod initialize-instance :after ((self Subjekt) &rest initargs)
  (with-slots (name instance-hash) self
    (format t "Instance-Hash is ~S for init-instance of ~A with ~S.~%"
            instance-hash name initargs)
    (let ((instance-alist (gethash name instance-hash))
          (my-type (type-of self)))
      (when (assoc my-type instance-alist)
        (error "Objekt ~S existiert bereits..." name))
      (setf (gethash name instance-hash)
            (acons my-type self instance-alist)))))

(defun demo ()
  (loop for i from 1 to 5
        do (make-instance 'Subjekt :name (format nil "Demo ~D" i))))

--SNIP--------------------------------------------------------------------

Any help and ideas, and best of all any bug-fix/work-around is _very_
appreciated, since the above problem crops up in a part of a
simulation framework I'm currently developping...

TIA

Regs, Pierre.

--

  "Such is life." -- Fiona in "Four Weddings and a Funeral" (UK/1994)



Fri, 08 Sep 2000 03:00:00 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Improvements to CMU CL's CLOS implementation

2. Installing CMU CL. Missing files?

3. Bug fix needed: METERING util for CMU CL

4. defstruct bug in CMU CL?

5. Running CL-HTTP w/ CMU-CL

6. How is CMU CL compared with commercial CL?

7. re bug, or am I missing something?

8. CLOS: slots with :allocation :class

9. CLOS slot :type property

10. CLOS :allocation slot types

11. CLOS: read only slots?

12. CLOS: initarg for a slot that's not there

 

 
Powered by phpBB® Forum Software