From: luke gruber Date: 2011-08-23T00:56:22+09:00 Subject: Re: Gritty Details of super() > The question is: Why isn't M's singleton class inserted into the > singleton class hierarchy? > > As to why that is? I have no idea. Things would be nice and > symmetrical if a module's singleton class did get inserted in the > singleton class hierarchy. > > (The method lookup diagrams were copied from Metaprogramming Ruby.) >7stud Thanks 7stud, that was exactly what I was trying to get at. The confusion I have with the current approach is this: If Ruby wanted us to forget about the whole anonymous superclass proxying the module on inclusion or extension, then in order for the module (which, in our mental makeup in this case is right above the class that included/extended the module), it would make the most sense for singleton methods called on our class to resolve/lookup the module's singleton methods upon a method_missing or super or whatever. However, this is not the case as we all know. So OK, maybe Ruby wants us to KNOW about the anonymous superclass that is proxying the module, and for this to not only be an implementation feature/hack, but a feature of the language that we can put in our mental model of method lookup. But if we put this in our mental model, then a couple of problems arise for me. First, ::ancestors. ::ancestors shows the module name, which is nice, but crumples our mental model a bit as it should show the anon superclass if our mental model was changed. The second problem/misunderstanding for me is that the anonymous superclass that proxies the module (ASCTPTM...hehe) does not proxy the singleton methods of the module. This for me, actually makes sense now. Of course it wouldn't, because only instance methods, CONSTANTS and @@variables are looked up. So with all that said, I guess I'm trying to say that, in my mind, Ruby is a little confused as to which mental model people are supposed to take, and in some cases these two mental models conflict a little. I'd love to hear your thoughts. Oh, and I'll reply to Robert later as he had some great points. Thanks all, -Luke -- Posted via http://www.ruby-forum.com/.