From: "David A. Black" Date: 2005-04-21T04:05:38+09:00 Subject: Re: [ANN] Article: Seeing Metaclasses Clearly Hi -- On Thu, 21 Apr 2005, Chris Pine wrote: >> instance_of? returns true or false; I'm just taking that literally. > > Well, it seems like some interpretation is perhaps called for. As has > been noted, 'Object.superclass' return 'nil'... and we don't want to > take that too literally! I think interpreting false as true in this case is a bit of a stretch :-) I'm not "against" the idea of an object being an instance of its singleton class in some general way. In fact, I'm fairly certain that I once wrote something along the lines of: every object is an instance of two classes... etc., somewhere. But if that's wrong, it's wrong; I don't want to second-guess it. >> I just don't want to >> create a terminological inconsistency that then has to be sort of >> re-explained or "asterisked" every time it comes up. > > Amen! Although, I feel like this is already the case... :) > > "Well, Ruby does say that the class is String, and we know that when > Ruby checks for methods, it starts with the class, then moves up the > inheritance chain... but really, it starts with the singleton class, > then up to any included modules in reverse order that they were > included, *then* up to String and so on..." > > I feel like to really explain the topic, you kind of have to say all that. But just don't tie yourself in that knot in the first place, and then you don't have to untie it :-) If you never say "we know that when Ruby checks for methods, it starts with the class...." then you never have to back out of it. >> I would actually be happy with >> #class becoming #birth_class, and being paired with #singleton_class >> (or #own_class), but one thing at a time :-) > > Yeah... I'm not sure. I'm fine with it as it is, I guess because it > looks easy to a beginner (which is important for a tutorial writer > like me). It is an over-simplification, but on the surface it makes > sense. Then, when you dig down, you learn that 'class' is, in > whatever sense, not telling you the "whole" truth. That's fine, too, > because at that point you are fairly advanced, and can handle it. > > I think it's great that you can do a lot of Ruby *without* having to > know this stuff. On the other hand (also from the point of view of a chronic explainer of Ruby :-) it's easier to say: Every object has a birth class and a singleton [or whatever] class, than: Every object has a class and a (class << self; self; end) :-) David -- David A. Black dblack@wobblini.net