On Thu, Mar 14, 2013 at 3:14 PM, Kedar Mhaswade <[email protected]> wrote:
> Robert Klemme wrote in post #1101602:
>> On Thu, Mar 14, 2013 at 2:42 PM, Kedar Mhaswade <[email protected]>
>> wrote:

>> The information may be right or outdated but it does not necessarily
>> help users of the language to understand how Ruby works.
>
> My observation too has been that this so-called anonymous class is not
> to be found via the :superclass method and I have already clarified that
> in the document as:
>
> -------------------------------------------------------------------
> This diagram is not entirely accurate because although Anonclass appears
> to become superclass of Someclass, just by the virtue of inclusion of
> module Mod,  Anonclass is not returned when you do Someclass.superclass.
> -------------------------------------------------------------------
>
> But if methods were only to be defined on class objects, I am not sure
> where the included module methods would come from without disturbing
> inheritance chain of classes.

You could model it like this: every class has a list of included
modules which is initially empty. Every time a module is included
which is not included in this class or any super class it is prepended
to the list.  Method lookup starts with the class itself, then
proceeds through the list of modules of this class and then proceeds
in the same way in the superclass; the process is stopped when the
first matching method is found.  If not matching method is found the
lookup process starts again with name "method_missing". (That process
with end in class BasicObject which has a definition of
#method_missing.)

> Any MRI experts -- how does it _really_ happen?
> And how about JRuby/Rubinius?

You can look it up in the implementation - it's OSS.

Kind regards

robert

-- 
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/

-- 
[email protected] | 
https://groups.google.com/d/forum/ruby-talk-google?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"ruby-talk-google" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to