[#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:02072] Re: Anonymous and Singleton Classes

From: B_DAVISON <Bob.Davison@...>
Date: 2000-03-22 09:57:39 UTC
List: ruby-talk #2072
Re: [ruby-talk:02062] Re: Anonymous and Singleton Classes

Matz,
  thanks for explaining this stuff to me, I'm sure that you must have explained
it enough before.

> Hmm, there was discussion about this matter before, without explicit
> conclusion.  Let's talk it again.  What should we call `class <<obj'
> statement?

As it contains the keyword 'class' I think that it will be difficult to try and
hide the fact that it is a class type operation.  I spent a lot of time
worrying about what wasn't being said and what was hinted at, FAQ 6.6's use of
'anonymous class' suggests parallels with Class::new() and the description of
super() in the FAQ talks of calling the method in the superclass which suggests
an inheritance relationship.

I think that 'singleton class' is fine, I just needed more help in coming to
terms with something that was so unfamiliar.  I am used to modifying the
behaviour of objects of the same class by supplying different
parameters/attributes, not by overriding complete operations.  Overriding to me
feels like an inheritance thing.

>I'm not sure how much I should describe implementation details.
>Conceptually, a class inherits singleton methods also from its
>superclass.  That's all.
>
>In current implementation, they are done by internal hidden class
>called `singleton class', which is real class of classes.  You can
>consider this hidden class a metaclass.  Better description is welcome.

That's fine by me.  I just got curious and a little confused when you talked
about the class of a class being a metaclass when MyClass.type returned Class. 
It took me a while to make the connection with the effects of adding singleton
methods or creating a singleton class.


>  def Class.inherited(c)
>    ...
>  end
>
>defines a class method of Class, which is shared by subclasses of
>Class.  C1 is a instance of Class, but not a subclass of Class. So you
>should have
>
>  class Class
>   def inherited(c)  # override default `inherited'
>     ...
>   end
>  end

Sorry about this one.  I realised what was going on shortly after posting the
message.


> By the way, how many times did I type `class' in this mail? :-)
>
>							matz.

I know how you feel.

.../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

Prev Next