[#1816] Ruby 1.5.3 under Tru64 (Alpha)? — Clemens Hintze <clemens.hintze@...>

Hi all,

17 messages 2000/03/14

[#1989] English Ruby/Gtk Tutorial? — schneik@...

18 messages 2000/03/17

[#2241] setter() for local variables — ts <decoux@...>

18 messages 2000/03/29

[ruby-talk:02050] Re: Anonymous and Singleton Classes

From: B_DAVISON <Bob.Davison@...>
Date: 2000-03-21 10:16:30 UTC
List: ruby-talk #2050
Hi,

Re: [ruby-talk:02045] Re: Anonymous and Singleton Classes

>Hi,
>
>In message "[ruby-talk:02036] Anonymous and Singleton Classes"
>    on 00/03/20, B_DAVISON <Bob.Davison@reuters.com> writes:
>
>|I am a Ruby newbie and having some problems getting my mind around certain
>|aspects of classes, especially anonymous classes and singleton classes.
>|
>|I composed a nice long mail to you all then realised that I should check the
>|mail archive first and found the February thread "Singleton Classes".  Now I
>am
>|even more confused!
>|
>|I had just decided that class << obj; ...; end didn't actually create an
>|anonymous class (even though FAQ 6.6 says it does) and then matz says that it
>|does.
>
>Two points:
>
>  (a) `Class::new' should call `inherited' because it creates new
>      anonymous subclass.  It's a bug.
>
>  (b) In current implementation singleton class statement creates
>      internal class, but it is just a virtual class, so that
>      `inherited' is not called for them.  I consder it a feature.
>
>							matz.

OK, so would I be right in saying that it's an implementation thing and you
want to keep that hidden so the implementation can change?  Perhaps using the
term 'class' in the description of these things is misleading (or might be in
the future if the implementation changes :-)

It a similar sort of thing going on with the class Class?  I was a bit confused
by the description of Class in the Ruby Reference Manual where you start
describing an unnamed meta-class that is actually the class of each class but
then say that it is complicated and stop.  Guessing from above is the class of
each class a singleton class of Class?

Would still be grateful for your help with the following though.
When I was trying to find out about subclasses I tried defining Class.inherited
 rather than C1.inherited and got no output even when creating a named
subclass.  To my mind C1 was an instance of Class and inherited an instance
method of Class therefore C1 should inherit Classes implementation of
inherited.

e.g.

def Class.inherited(subclass)
  print ">>> inherited ", subclass, "\n"
end

class C1
end

class C2 < C1
end

and nothing is output.

Thanks,
Bob

-----------------------------------------------------------------
        Visit our Internet site at http://www.reuters.com

Any views expressed in this message are those of  the  individual
sender,  except  where  the sender specifically states them to be
the views of Reuters Ltd.

In This Thread