Hi --

On Wed, 8 Nov 2006, ara.t.howard / noaa.gov wrote:

> On Wed, 8 Nov 2006 dblack / wobblini.net wrote:
>
>>> yes.  put another way, and something i was be-moaning several years ago, 
>>> is
>>> this:
>>>
>>>    harp:~ > cat a.rb
>>>    class A
>>>      SINGLETON_CLASS = class << self
>>>        self
>>>      end
>>>    end
>>>    class B < A
>>>      SINGLETON_CLASS = class << self
>>>        self
>>>      end
>>>    end
>>>
>>>    p B::SINGLETON_CLASS.ancestors
>>>
>>>    harp:~ > ruby a.rb
>>>    [Class, Module, Object, Kernel]
>>> 
>>> singleton classes should respect inheritence.
>> 
>> I'm not sure what you mean here.  Is it that ancestors doesn't show
>> singleton classes?
>
> i meant that B's singleton class should inherit from A's singleton
> class - the fact that it does not leads to all sorts of suprising
> behaviour...

I'm still not seeing where your example fits in with this (I assume
I'm just being thick and not seeing what's right in front of me) --
but I'll forge ahead and note that the question of the subclass
relation of singleton classes seems to have swung back and forth.  In
1.8.2, this was true (given the usual singleton_class method):

   B.singleton_class.superclass == A.singleton_class

and it's true in fairly recent 1.9, but not true in 1.8.5.  I have no
idea why not.  B.meth still looks in A's singleton class for "meth",
but apparently inheritance is not used as the mechanism.


David

-- 
                   David A. Black | dblack / wobblini.net
Author of "Ruby for Rails"   [1] | Ruby/Rails training & consultancy [3]
DABlog (DAB's Weblog)        [2] | Co-director, Ruby Central, Inc.   [4]
[1] http://www.manning.com/black | [3] http://www.rubypowerandlight.com
[2] http://dablog.rubypal.com    | [4] http://www.rubycentral.org