eieio.el: initialize-instance: strange behavior with simple class hierarchy

Jan Moringen <[email protected]> Sat, 26 Sep 2009 03:46:31 +0200
Newsgroups gmane.emacs.eieio
Message-ID <9811_1253929593_ZZg0F5P1MKs3J.00_1253929591.24164.67.camel@localhost.localdomain>
--Boundary_(ID_XbHSPPiytUuxsvuRPJvy8g)
Content-type: text/plain; charset=UTF-8
Content-transfer-encoding: 7BIT

Hi,

I think I may have found a bug in EIEIO. If it is not a bug, it is at
least surprising behavior.

I discovered the problem when working with a class hierarchy that looks
like this

a
+-d

b
+-c
  +-d

a and b have initialize-instance :after methods, d has a primary
initialize-instance method.

When creating a d object, I expect the constructors to run as follows:

     1. (initialize-instance d)
     2. (initialize-instance b)
     3. (initialize-instance a)

or

     1. (initialize-instance d) 
     2. (initialize-instance a) 
     3. (initialize-instance b)

but what really happens is

     1. (initialize-instance d) 
     2. (initialize-instance b) 
     3. (initialize-instance a)
     4. (initialize-instance b)
     5. (initialize-instance a)

I think, this is wrong, but maybe I did not understand :after or
call-next-method correctly.

Redefining the involved classes and methods changes something and
sometimes makes the duplicate runs go away.

The attached code should produce the problem with CVS CEDET.

Any help would be greatly appreciated.

Kind regards,
Jan

--Boundary_(ID_XbHSPPiytUuxsvuRPJvy8g)
Content-type: text/x-emacs-lisp; name=bla.el; charset=UTF-8
Content-transfer-encoding: 7BIT
Content-disposition: attachment; filename=bla.el

(defclass a ()
  ())

(defmethod initialize-instance :after ((this a) &rest slots)
  (message "+a")

  (when (next-method-p)
    (call-next-method))

  (message "-a"))

(defclass b ()
  ())

(defmethod initialize-instance :after ((this b) &rest slots)
  (message "+b")

  (when (next-method-p)
    (call-next-method))

  (message "-b"))

(defclass c (b)
  ())

(defclass d (c a)
  ())

(defmethod initialize-instance ((this d) &rest slots)
  (message "+d")

  (when (next-method-p)
    (call-next-method))

  (message "-d"))

(d "test")



;; +d
;; -d
;; +b
;; -b
;; +a
;; -a
;; +b
;; -b
;; +a
;; -a

--Boundary_(ID_XbHSPPiytUuxsvuRPJvy8g)
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

------------------------------------------------------------------------------
Come build with us! The BlackBerry&reg; Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9&#45;12, 2009. Register now&#33;
http://p.sf.net/sfu/devconf
--Boundary_(ID_XbHSPPiytUuxsvuRPJvy8g)
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
cedet-eieio mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/cedet-eieio

--Boundary_(ID_XbHSPPiytUuxsvuRPJvy8g)--