[Date Prev][Date Next][Thread Prev][][Date Index][Thread Index]

Re: Problem with sb-rss-hash (bug in luna?)



David Engster <deng@xxxxxxxxxxxxxxx> writes:
>> Katsumi Yamaoka <yamaoka@xxxxxxx> writes:
>>> But we seem to have no smart solution so far, except for a workaround.
>>> That is, Arisawa-san provided the `shimbun-rss-initialize-ignored-subject'
>>> function and modified sb-itmedia.el and sb-opentechpress-jp.el so as to
>>> use it in the `initialize-instance' method as follows:

[...]

> However, I still wonder why the initialize-instance :after method from
> sb-rss is not called. I don't think that one should have to do the
> initialization for the ignored-subject slot explicitly.

Hi, it's me again. :-)

I think I now know what's going wrong. We have:

     shimbun
    /       \
 sb-hash   sb-rss
    \       /
   sb-rss-hash

Now, let's say all classes have a 'initialize-instance :after'
method. If you make an instance of sb-rss-hash, these would have to be
called in the following order:

1. shimbun
2. sb-rss
3. sb-hash
4. sb-rss-hash

This is because of each class being more specific than its superclasses,
and that for a given class, superclasses listed earlier are more
specific than those listed later (see for example
http://www.aiai.ed.ac.uk/~jeff/clos-guide.html).

Now, if you look at luna-class-find-functions, you'll see that it does a
recursion which always prefers the parent, meaning that in our example,
it goes 

sb-rss-hash -> sb-hash -> shimbun

without ever looking at sb-rss.

The question is, should sb-rss-hash just be changed to deal with this
behaviour, or should luna.el be fixed? Is there someone still
maintaining luna.el?

Regards,
David

PS: Here's a small example demonstrating the above behaviour:

Luna:

(require 'luna)
(luna-define-class mybase () () )
(luna-define-method initialize-instance :after ((c mybase) &rest args)
  (message "mybase"))
(luna-define-class myparent1 (mybase) () )
(luna-define-method initialize-instance :after ((c myparent1) &rest args)
  (message "myparent1"))
(luna-define-class myparent2 (mybase) () )
(luna-define-method initialize-instance :after ((c myparent2) &rest args)
  (message "myparent2"))
(luna-define-class newclass (myparent1 myparent2) () )
(luna-define-method initialize-instance :after ((c newclass) &rest args)
  (message "newclass"))
(luna-make-entity 'newclass)

Output: mybase myparent1 newclass

With EIEIO library (which does it correct):

(load-file "~/cedet/common/cedet.el")
(defclass mybase () () )
(defmethod initialize-instance :after ((c mybase) &rest args)
	   (message "mybase"))
(defclass myparent1 (mybase) () )
(defmethod initialize-instance :after ((c myparent1) &rest args)
	   (message "myparent1"))
(defclass myparent2 (mybase) () )
(defmethod initialize-instance :after ((c myparent2) &rest args)
	   (message "myparent2"))
(defclass newclass (myparent1 myparent2) () )
(defmethod initialize-instance :after ((c newclass) &rest args)
	   (message "newclass"))
(make-instance 'newclass)

Output: mybase myparent2 myparent1 newclass