# Error in ancestor?

**URL:** <https://rubytalk.org/t/error-in-ancestor/38405>\
**Category:** ruby-talk\
**Created:** [16 June 2007 13:56 UTC](https://rubytalk.org/t/error-in-ancestor/38405 "2007-06-16T13:56:00Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Forum](https://avatars.discourse-cdn.com/v4/letter/f/43a26b/32.png) [@Forum](https://rubytalk.org/u/Forum)\
**Post date:** [16 June 2007 13:56 UTC](https://rubytalk.org/t/error-in-ancestor/38405/1 "2007-06-16T13:56:00Z")

</div>

Hi list

I just observed this (and it cost me quite some effort to debug my code ☹ )

515/15 \> ruby -ve 'class \<\< Class::new; puts self; puts ancestors.inspect end'  
ruby 1.8.5 (2006-12-04 patchlevel 2) [i686-linux]  
#\<Class:#\<Class:0xb7dfae50\>\>  
[Class, Module, Object, Kernel]

this seems to be in contradiction with  
[http://www.ruby-doc.org/core/classes/Module.html#M001700](http://www.ruby-doc.org/core/classes/Module.html#M001700)  
stating

> **···**
>
> -----------------------------------------------------------------------------  
> &nbsp;&nbsp;mod.ancestors → array
> 
> Returns a list of modules included in mod (including mod itself).  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=============
> 
> &nbsp;&nbsp;&nbsp;module Mod  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;include Math  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;include Comparable  
> &nbsp;&nbsp;&nbsp;end
> 
> &nbsp;&nbsp;&nbsp;Mod.ancestors #=\> [Mod, Comparable, Math]  
> &nbsp;&nbsp;&nbsp;Math.ancestors #=\> [Math]  
> ---------------------------------------------------------------------------
> 
> Is this an error in doc or in behavior?
> 
> Cheers  
> Robert
> 
> --  
> You see things; and you say Why?  
> But I dream things that never were; and I say Why not?  
> -- George Bernard Shaw

---

<div class="post-metadata">

**Author:** ![James\_Britt](https://avatars.discourse-cdn.com/v4/letter/j/22d042/32.png) [@James\_Britt](https://rubytalk.org/u/James_Britt)\
**Post date:** [16 June 2007 14:24 UTC](https://rubytalk.org/t/error-in-ancestor/38405/2 "2007-06-16T14:24:45Z")

</div>

> Hi list
> 
> I just observed this (and it cost me quite some effort to debug my code ☹ )
> 
> 515/15 \> ruby -ve 'class \<\< Class::new; puts self; puts ancestors.inspect end'  
> ruby 1.8.5 (2006-12-04 patchlevel 2) [i686-linux]  
> #\<Class:#\<Class:0xb7dfae50\>\>  
> [Class, Module, Object, Kernel]
> 
> this seems to be in contradiction with  
> [class Module - RDoc Documentation](http://www.ruby-doc.org/core/classes/Module.html#M001700)  
> stating  
> -----------------------------------------------------------------------------  
> mod.ancestors → array
> 
> Returns a list of modules included in mod (including mod itself).  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=============
> 
> &nbsp;&nbsp;module Mod  
> &nbsp;&nbsp;&nbsp;&nbsp;include Math  
> &nbsp;&nbsp;&nbsp;&nbsp;include Comparable  
> &nbsp;&nbsp;end
> 
> &nbsp;&nbsp;Mod.ancestors #=\> [Mod, Comparable, Math]  
> &nbsp;&nbsp;Math.ancestors #=\> [Math]  
> ---------------------------------------------------------------------------
> 
> Is this an error in doc or in behavior?
> 
> Cheers  
> Robert
> 
> --  
> You see things; and you say Why?  
> But I dream things that never were; and I say Why not?  
> -- George Bernard Shaw

What error?  
It works as described ModuleName.ancestors returns an array including itself and its ancestors.

irb(main):034:0\> Array.ancestors  
=\> [Array, Enumerable, Object, Kernel]  
irb(main):035:0\> Class.ancestors  
=\> [Class, Module, Object, Kernel]

Perhaps it does blur the lines of the term module  
Module  
Mod  
Module is the Class Name that recent versions of Ruby respond to, Mod is apparently an old synonym that is still in the Rdoc, but Ruby doesn't recognize it, it could be a mistake in the docs, but it could also be an old alias...

irb(main):036:0\> Mod.ancestors  
NameError: uninitialized constant Mod  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from (irb):36  
irb(main):037:0\> Module.ancestors  
=\> [Module, Object, Kernel]

> **···**
>
> On Jun 16, 2007, at 8:56 AM, Robert Dober wrote:  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from :0

---

<div class="post-metadata">

**Author:** ![Morton\_Goldberg](https://avatars.discourse-cdn.com/v4/letter/m/7ea924/32.png) [@Morton\_Goldberg](https://rubytalk.org/u/Morton_Goldberg)\
**Post date:** [16 June 2007 16:52 UTC](https://rubytalk.org/t/error-in-ancestor/38405/3 "2007-06-16T16:52:55Z")

</div>

It cost me some effort to figure out what the question really was :), but I presume you're wondering why the singleton class doesn't appear in the ancestor list. I don't know the answer, but I think the question is posed more clearly when the example is constructed for the singleton class of an ordinary object.

\<code\>  
class Foo; end  
Bar = class \<\< Foo.new; self; end  
Bar # =\> #\<Class:#\<Foo:0x20e18\>\>  
Bar.ancestors # =\> [Foo, Object, Kernel]  
\</code\>

If I had to make a call, I would say that the documentation had inadvertently omitted a very special case.

Regards, Morton

P.S. Why 'puts ancestors.inspect' instead of the simpler 'p ancestors'?

> **···**
>
> On Jun 16, 2007, at 9:56 AM, Robert Dober wrote:
> 
> > Hi list
> > 
> > I just observed this (and it cost me quite some effort to debug my code ☹ )
> > 
> > 515/15 \> ruby -ve 'class \<\< Class::new; puts self; puts ancestors.inspect end'  
> > ruby 1.8.5 (2006-12-04 patchlevel 2) [i686-linux]  
> > #\<Class:#\<Class:0xb7dfae50\>\>  
> > [Class, Module, Object, Kernel]
> > 
> > this seems to be in contradiction with  
> > [class Module - RDoc Documentation](http://www.ruby-doc.org/core/classes/Module.html#M001700)  
> > stating  
> > -----------------------------------------------------------------------------  
> > mod.ancestors → array
> > 
> > Returns a list of modules included in mod (including mod itself).  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=============
> > 
> > &nbsp;&nbsp;module Mod  
> > &nbsp;&nbsp;&nbsp;&nbsp;include Math  
> > &nbsp;&nbsp;&nbsp;&nbsp;include Comparable  
> > &nbsp;&nbsp;end
> > 
> > &nbsp;&nbsp;Mod.ancestors #=\> [Mod, Comparable, Math]  
> > &nbsp;&nbsp;Math.ancestors #=\> [Math]  
> > ---------------------------------------------------------------------------
> > 
> > Is this an error in doc or in behavior?

---

<div class="post-metadata">

**Author:** ![Sylvain\_Joyeux](https://avatars.discourse-cdn.com/v4/letter/s/96bed5/32.png) [@Sylvain\_Joyeux](https://rubytalk.org/u/Sylvain_Joyeux)\
**Post date:** [18 June 2007 13:14 UTC](https://rubytalk.org/t/error-in-ancestor/38405/4 "2007-06-18T13:14:31Z")

</div>

I launched a discussion about this on Ruby-core. I think there were no  
consensus on this at the time.

See ruby-core:9604. Tom closed the related bug, but maybe I should re-open  
it since, as far as I remember, there has been no final conclusion.

> **···**
>
> --  
> Sylvain Joyeux

---

<div class="post-metadata">

**Author:** ![Forum](https://avatars.discourse-cdn.com/v4/letter/f/43a26b/32.png) [@Forum](https://rubytalk.org/u/Forum)\
**Post date:** [16 June 2007 15:43 UTC](https://rubytalk.org/t/error-in-ancestor/38405/5 "2007-06-16T15:43:06Z")

</div>

This error  
ruby -ve 'class \<\< Class::new; puts ancestors.include?( self ) end'  
ruby 1.8.5 (2006-12-04 patchlevel 2) [i686-linux]  
false  
Robert

> **···**
>
> On 6/16/07, John Joyce \<dangerwillrobinsondanger@gmail.com\> wrote:
> 
> > On Jun 16, 2007, at 8:56 AM, Robert Dober wrote:
> > 
> > \> Hi list  
> > \>  
> > \> I just observed this (and it cost me quite some effort to debug my  
> > \> code ☹ )  
> > \>  
> > \> 515/15 \> ruby -ve 'class \<\< Class::new; puts self; puts  
> > \> ancestors.inspect end'  
> > \> ruby 1.8.5 (2006-12-04 patchlevel 2) [i686-linux]  
> > \> #\<Class:#\<Class:0xb7dfae50\>\>  
> > \> [Class, Module, Object, Kernel]  
> > \>  
> > \> this seems to be in contradiction with  
> > \> [class Module - RDoc Documentation](http://www.ruby-doc.org/core/classes/Module.html#M001700)  
> > \> stating  
> > \> ----------------------------------------------------------------------  
> > \> -------  
> > \> mod.ancestors → array  
> > \>  
> > \> Returns a list of modules included in mod (including mod itself).  
> > \>  
> > \> =============  
> > \>  
> > \> module Mod  
> > \> include Math  
> > \> include Comparable  
> > \> end  
> > \>  
> > \> Mod.ancestors #=\> [Mod, Comparable, Math]  
> > \> Math.ancestors #=\> [Math]  
> > \> ----------------------------------------------------------------------  
> > \> -----  
> > \>  
> > \> Is this an error in doc or in behavior?  
> > \>  
> > \> Cheers  
> > \> Robert  
> > \>  
> > \> --  
> > \> You see things; and you say Why?  
> > \> But I dream things that never were; and I say Why not?  
> > \> -- George Bernard Shaw  
> > \>  
> > What error?

---

<div class="post-metadata">

**Author:** ![Forum](https://avatars.discourse-cdn.com/v4/letter/f/43a26b/32.png) [@Forum](https://rubytalk.org/u/Forum)\
**Post date:** [16 June 2007 18:36 UTC](https://rubytalk.org/t/error-in-ancestor/38405/6 "2007-06-16T18:36:35Z")

</div>

> \> Hi list  
> \>  
> \> I just observed this (and it cost me quite some effort to debug my  
> \> code ☹ )  
> \>  
> \> 515/15 \> ruby -ve 'class \<\< Class::new; puts self; puts  
> \> ancestors.inspect end'  
> \> ruby 1.8.5 (2006-12-04 patchlevel 2) [i686-linux]  
> \> #\<Class:#\<Class:0xb7dfae50\>\>  
> \> [Class, Module, Object, Kernel]  
> \>  
> \> this seems to be in contradiction with  
> \> [http://www.ruby-doc.org/core/classes/Module.html#M001700](http://www.ruby-doc.org/core/classes/Module.html#M001700)  
> \> stating  
> \> ----------------------------------------------------------------------  
> \> -------  
> \> mod.ancestors → array  
> \>  
> \> Returns a list of modules included in mod (including mod itself).  
> \>  
> \> =============  
> \>  
> \> module Mod  
> \> include Math  
> \> include Comparable  
> \> end  
> \>  
> \> Mod.ancestors #=\> [Mod, Comparable, Math]  
> \> Math.ancestors #=\> [Math]  
> \> ----------------------------------------------------------------------  
> \> -----  
> \>  
> \> Is this an error in doc or in behavior?
> 
> It cost me some effort to figure out what the question really  
> was :), but I presume you're wondering why the singleton class

I know in ruby I would say  
assert didactic\_skills.zero? # ☹

> doesn't appear in the ancestor list. I don't know the answer, but I  
> think the question is posed more clearly when the example is  
> constructed for the singleton class of an ordinary object.
> 
> \<code\>  
> class Foo; end  
> Bar = class \<\< Foo.new; self; end  
> Bar # =\> #\<Class:#\<Foo:0x20e18\>\>  
> Bar.ancestors # =\> [Foo, Object, Kernel]  
> \</code\>

Sure thanks for adding this

> If I had to make a call, I would say that the documentation had  
> inadvertently omitted a very special case.

Very probable given the code in class.c

> Regards, Morton
> 
> P.S. Why 'puts ancestors.inspect' instead of the simpler 'p ancestors'?

Because output is shorter and more readable. I often get bitten by  
debugging output  
puts ary1  
puts ary2  
### Where the heck does ary2 start?

so I developed a reflex to use inspect for all kind of  
debugging/demonstrating output.  
I feel it is goo[df] practice.

Cheers  
Robert

> **···**
>
> On 6/16/07, Morton Goldberg \<m\_goldberg@ameritech.net\> wrote:
> 
> > On Jun 16, 2007, at 9:56 AM, Robert Dober wrote:
> 
> --  
> You see things; and you say Why?  
> But I dream things that never were; and I say Why not?  
> -- George Bernard Shaw

---

<div class="post-metadata">

**Author:** ![Forum](https://avatars.discourse-cdn.com/v4/letter/f/43a26b/32.png) [@Forum](https://rubytalk.org/u/Forum)\
**Post date:** [19 June 2007 13:12 UTC](https://rubytalk.org/t/error-in-ancestor/38405/7 "2007-06-19T13:12:03Z")

</div>

Merci Sylvain

I do not want to argue with the wise guys if it is an error - I  
clearly thought so but that is not important 😉  
But it really would have saved me an hour of debugging if the doc  
stated clearly that singletons are not included. I thought this might  
help others and as it took me 20s to vim the missing line into class.c  
- I sent it up to core.

Do you think I should handle this differently?

Cheers  
Robert

> **···**
>
> On 6/18/07, Sylvain Joyeux \<sylvain.joyeux@polytechnique.org\> wrote:
> 
> > I launched a discussion about this on Ruby-core. I think there were no  
> > consensus on this at the time.
> > 
> > See ruby-core:9604. Tom closed the related bug, but maybe I should re-open  
> > it since, as far as I remember, there has been no final conclusion.  
> > --  
> > Sylvain Joyeux
> 
> --  
> You see things; and you say Why?  
> But I dream things that never were; and I say Why not?  
> -- George Bernard Shaw

---

<div class="post-metadata">

**Author:** ![James\_Britt](https://avatars.discourse-cdn.com/v4/letter/j/22d042/32.png) [@James\_Britt](https://rubytalk.org/u/James_Britt)\
**Post date:** [16 June 2007 18:35 UTC](https://rubytalk.org/t/error-in-ancestor/38405/8 "2007-06-16T18:35:14Z")

</div>

If you're expecting it to return true, it can't. Everything in the array is an instance, not the class itself.

> **···**
>
> On Jun 16, 2007, at 10:43 AM, Robert Dober wrote:
> 
> > On 6/16/07, John Joyce \<dangerwillrobinsondanger@gmail.com\> wrote:
> > 
> > > On Jun 16, 2007, at 8:56 AM, Robert Dober wrote:
> > > 
> > > \> Hi list  
> > > \>  
> > > \> I just observed this (and it cost me quite some effort to debug my  
> > > \> code ☹ )  
> > > \>  
> > > \> 515/15 \> ruby -ve 'class \<\< Class::new; puts self; puts  
> > > \> ancestors.inspect end'  
> > > \> ruby 1.8.5 (2006-12-04 patchlevel 2) [i686-linux]  
> > > \> #\<Class:#\<Class:0xb7dfae50\>\>  
> > > \> [Class, Module, Object, Kernel]  
> > > \>  
> > > \> this seems to be in contradiction with  
> > > \> [class Module - RDoc Documentation](http://www.ruby-doc.org/core/classes/Module.html#M001700)  
> > > \> stating  
> > > \> ----------------------------------------------------------------------  
> > > \> -------  
> > > \> mod.ancestors → array  
> > > \>  
> > > \> Returns a list of modules included in mod (including mod itself).  
> > > \>  
> > > \> =============  
> > > \>  
> > > \> module Mod  
> > > \> include Math  
> > > \> include Comparable  
> > > \> end  
> > > \>  
> > > \> Mod.ancestors #=\> [Mod, Comparable, Math]  
> > > \> Math.ancestors #=\> [Math]  
> > > \> ----------------------------------------------------------------------  
> > > \> -----  
> > > \>  
> > > \> Is this an error in doc or in behavior?  
> > > \>  
> > > \> Cheers  
> > > \> Robert  
> > > \>  
> > > \> --  
> > > \> You see things; and you say Why?  
> > > \> But I dream things that never were; and I say Why not?  
> > > \> -- George Bernard Shaw  
> > > \>  
> > > What error?
> > 
> > This error  
> > ruby -ve 'class \<\< Class::new; puts ancestors.include?( self ) end'  
> > ruby 1.8.5 (2006-12-04 patchlevel 2) [i686-linux]  
> > false  
> > Robert

---

<div class="post-metadata">

**Author:** ![Morton\_Goldberg](https://avatars.discourse-cdn.com/v4/letter/m/7ea924/32.png) [@Morton\_Goldberg](https://rubytalk.org/u/Morton_Goldberg)\
**Post date:** [16 June 2007 20:54 UTC](https://rubytalk.org/t/error-in-ancestor/38405/9 "2007-06-16T20:54:43Z")

</div>

But isn't 'p \<expression\>' shorthand for 'puts (\<expression\>).inspect'? If this is the case and AFAIK it is, then you just need to develop a new reflex to use p.

Regards, Morton

> **···**
>
> On Jun 16, 2007, at 2:36 PM, Robert Dober wrote:
> 
> > On 6/16/07, Morton Goldberg \<m\_goldberg@ameritech.net\> wrote:
> > 
> > > P.S. Why 'puts ancestors.inspect' instead of the simpler 'p ancestors'?
> > 
> > Because output is shorter and more readable. I often get bitten by  
> > debugging output  
> > puts ary1  
> > puts ary2  
> > ### Where the heck does ary2 start?
> > 
> > so I developed a reflex to use inspect for all kind of  
> > debugging/demonstrating output.  
> > I feel it is goo[df] practice.

---

<div class="post-metadata">

**Author:** ![Rick\_DeNatale1](https://avatars.discourse-cdn.com/v4/letter/r/bbce88/32.png) [@Rick\_DeNatale1](https://rubytalk.org/u/Rick_DeNatale1)\
**Post date:** [19 June 2007 16:19 UTC](https://rubytalk.org/t/error-in-ancestor/38405/10 "2007-06-19T16:19:46Z")

</div>

As far as I can tell, singleton classes aren't mentioned in the doc.  
The documentation borders on folklore.

Singletons as a means of implementing both individual instance, and  
class behavior have a position like "the man behind the curtain" in  
"The Wizard of OZ." We're really supposed to disregard them. \<G\>

Coming from a background in Smalltalk, my preference would be if this  
machinery were more visible and official, but Matz has his reasons for  
not doing so. For one thing, not documenting it, and hiding it from  
methods like ancestors and class makes it easier to tinker with as the  
language evolves without "officially" breaking backward compatibility.

I wrote a bit more about this a couple of months ago  
[http://frodo:4072/articles/2007/04/23/ideas-for-improving-ruby](http://frodo:4072/articles/2007/04/23/ideas-for-improving-ruby)

look in the section "Free the metaclass"

But those are just my opinions, I'm just glad I'm here!

> **···**
>
> On 6/19/07, Robert Dober \<robert.dober@gmail.com\> wrote:
> 
> > I do not want to argue with the wise guys if it is an error - I  
> > clearly thought so but that is not important 😉  
> > But it really would have saved me an hour of debugging if the doc  
> > stated clearly that singletons are not included. I thought this might  
> > help others and as it took me 20s to vim the missing line into class.c
> 
> --  
> Rick DeNatale
> 
> My blog on Ruby  
> [http://talklikeaduck.denhaven2.com/](http://talklikeaduck.denhaven2.com/)

---

<div class="post-metadata">

**Author:** ![Forum](https://avatars.discourse-cdn.com/v4/letter/f/43a26b/32.png) [@Forum](https://rubytalk.org/u/Forum)\
**Post date:** [16 June 2007 19:46 UTC](https://rubytalk.org/t/error-in-ancestor/38405/11 "2007-06-16T19:46:12Z")

</div>

Getting bitten by my didactic skills 😉  
John please have a look at Morton's code, he was so kind to explain  
what I am worried about much clearer.  
That said maybe I can make things clearer myself:  
irb(main):001:0\> a = class A; ancestors end  
=\> [A, Object, Kernel]  
irb(main):002:0\> a.include? A  
=\> true  
irb(main):003:0\> B = Class::new  
=\> B  
irb(main):004:0\> Bsingle = class \<\< B ; self end  
=\> #\<Class:B\>  
irb(main):005:0\> b = Bsingle.ancestors  
=\> [#\<Class:B\>, #\<Class:Object\>, Class, Module, Object, Kernel]  
#Ah too bad my patched Ruby, I gotta recompile, sorry, normally the  
singletons are #not in ancestor, please execute the code yourself to  
see the difference.  
irb(main):006:0\> b.include? Bsingle  
=\> true

Cheers  
Robert

> **···**
>
> On 6/16/07, John Joyce \<dangerwillrobinsondanger@gmail.com\> wrote:
> 
> > If you're expecting it to return true, it can't. Everything in the  
> > array is an instance, not the class itself.
> 
> --  
> You see things; and you say Why?  
> But I dream things that never were; and I say Why not?  
> -- George Bernard Shaw

---

<div class="post-metadata">

**Author:** ![Forum](https://avatars.discourse-cdn.com/v4/letter/f/43a26b/32.png) [@Forum](https://rubytalk.org/u/Forum)\
**Post date:** [16 June 2007 21:09 UTC](https://rubytalk.org/t/error-in-ancestor/38405/12 "2007-06-16T21:09:50Z")

</div>

> \>\> P.S. Why 'puts ancestors.inspect' instead of the simpler 'p  
> \>\> ancestors'?  
> \>  
> \> Because output is shorter and more readable. I often get bitten by  
> \> debugging output  
> \> puts ary1  
> \> puts ary2  
> \> ### Where the heck does ary2 start?  
> \>  
> \> so I developed a reflex to use inspect for all kind of  
> \> debugging/demonstrating output.  
> \> I feel it is goo[df] practice.
> 
> But isn't 'p \<expression\>' shorthand for 'puts  
> (\<expression\>).inspect'? If this is the case and AFAIK it is, then  
> you just need to develop a new reflex to use p.

Ah you said p, not puts, that's quite clever...  
LOL you are an eagle eye, but you are right of course.  
Robert  
And yes you can chose the f above 😉

> **···**
>
> On 6/16/07, Morton Goldberg \<m\_goldberg@ameritech.net\> wrote:
> 
> > On Jun 16, 2007, at 2:36 PM, Robert Dober wrote:  
> > \> On 6/16/07, Morton Goldberg \<m\_goldberg@ameritech.net\> wrote:
> 
> > Regards, Morton
> 
> --  
> You see things; and you say Why?  
> But I dream things that never were; and I say Why not?  
> -- George Bernard Shaw

---

<div class="post-metadata">

**Author:** ![Forum](https://avatars.discourse-cdn.com/v4/letter/f/43a26b/32.png) [@Forum](https://rubytalk.org/u/Forum)\
**Post date:** [19 June 2007 18:46 UTC](https://rubytalk.org/t/error-in-ancestor/38405/13 "2007-06-19T18:46:16Z")

</div>

I'd surely love to read this but I constantly get a timeout at this link ☹  
Given the name of your box I am afraid that this URL comes from your  
local name resolution, would you have a DNS name?  
Thx in advance

Robert

> **···**
>
> On 6/19/07, Rick DeNatale \<rick.denatale@gmail.com\> wrote:
> 
> > On 6/19/07, Robert Dober \<robert.dober@gmail.com\> wrote:
> > 
> > I wrote a bit more about this a couple of months ago  
> > [http://frodo:4072/articles/2007/04/23/ideas-for-improving-ruby](http://frodo:4072/articles/2007/04/23/ideas-for-improving-ruby)
> > 
> > look in the section "Free the metaclass"
> 
> --  
> You see things; and you say Why?  
> But I dream things that never were; and I say Why not?  
> -- George Bernard Shaw

---

<div class="post-metadata">

**Author:** ![David\_A\_Black3](https://avatars.discourse-cdn.com/v4/letter/d/6a8cbe/32.png) [@David\_A\_Black3](https://rubytalk.org/u/David_A_Black3)\
**Post date:** [19 June 2007 22:29 UTC](https://rubytalk.org/t/error-in-ancestor/38405/14 "2007-06-19T22:29:10Z")

</div>

Hi --

> > I do not want to argue with the wise guys if it is an error - I  
> > clearly thought so but that is not important 😉  
> > But it really would have saved me an hour of debugging if the doc  
> > stated clearly that singletons are not included. I thought this might  
> > help others and as it took me 20s to vim the missing line into class.c
> 
> As far as I can tell, singleton classes aren't mentioned in the doc.  
> The documentation borders on folklore.
> 
> Singletons as a means of implementing both individual instance, and  
> class behavior have a position like "the man behind the curtain" in  
> "The Wizard of OZ." We're really supposed to disregard them. \<G\>
> 
> Coming from a background in Smalltalk, my preference would be if this  
> machinery were more visible and official, but Matz has his reasons for  
> not doing so. For one thing, not documenting it, and hiding it from  
> methods like ancestors and class makes it easier to tinker with as the  
> language evolves without "officially" breaking backward compatibility.

Does that mean that no one who's ever used Smalltalk can ever think  
that it's right for Ruby to deviate from Smalltalk? 🙂 I ask in a  
humorous spirit -- and also because it gives me an excuse to mention:

> **[Coming From Ruby](https://www.infoq.com/articles/coming-from-ruby/)**
>
> Do you "come from" a particular programming language? If so, that's great — but don't forget to take each language on its own terms. David A. Black shares some thoughts about "coming from" a language, and the etiquette of language travel, in the...

🙂

I think the singleton class has always had a somewhat equivocal  
position. I tend to root for it being treated as a real class, if a  
somewhat special-purposed one, since it \*is\* a real class (and neither  
virtual nor meta). That could change, of course. Matz has always  
described it as just the way that per-object behavior happens to be  
implemented in Ruby -- and a case could certainly be made that classes  
are an odd choice for that, since, while there are no hard-and-fast  
rules about it, the first things most of us probably think of are  
instantiation and inheritance and such, none of which can happen with  
a singleton class.

Kernel#singleton\_class would help a lot... or #singleton\_module, if it  
goes in that direction 🙂

David

> **···**
>
> On Wed, 20 Jun 2007, Rick DeNatale wrote:
> 
> > On 6/19/07, Robert Dober \<robert.dober@gmail.com\> wrote:
> 
> --  
> \* Books:  
> &nbsp;&nbsp;&nbsp;RAILS ROUTING (new! [http://safari.awprofessional.com/9780321509246\](http://safari.awprofessional.com/9780321509246%5C))  
> &nbsp;&nbsp;&nbsp;RUBY FOR RAILS ([http://www.manning.com/black\](http://www.manning.com/black%5C))  
> \* Ruby/Rails training  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& consulting: Ruby Power and Light, LLC ([http://www.rubypal.com](http://www.rubypal.com))

---

<div class="post-metadata">

**Author:** ![James\_Britt](https://avatars.discourse-cdn.com/v4/letter/j/22d042/32.png) [@James\_Britt](https://rubytalk.org/u/James_Britt)\
**Post date:** [16 June 2007 22:37 UTC](https://rubytalk.org/t/error-in-ancestor/38405/15 "2007-06-16T22:37:34Z")

</div>

Actually p is more like a short form for  
puts object.inspect

> **···**
>
> On Jun 16, 2007, at 4:09 PM, Robert Dober wrote:
> 
> > On 6/16/07, Morton Goldberg \<m\_goldberg@ameritech.net\> wrote:
> > 
> > > On Jun 16, 2007, at 2:36 PM, Robert Dober wrote:
> > > 
> > > \> On 6/16/07, Morton Goldberg \<m\_goldberg@ameritech.net\> wrote:  
> > > \>\> P.S. Why 'puts ancestors.inspect' instead of the simpler 'p  
> > > \>\> ancestors'?  
> > > \>  
> > > \> Because output is shorter and more readable. I often get bitten by  
> > > \> debugging output  
> > > \> puts ary1  
> > > \> puts ary2  
> > > \> ### Where the heck does ary2 start?  
> > > \>  
> > > \> so I developed a reflex to use inspect for all kind of  
> > > \> debugging/demonstrating output.  
> > > \> I feel it is goo[df] practice.
> > > 
> > > But isn't 'p \<expression\>' shorthand for 'puts  
> > > (\<expression\>).inspect'? If this is the case and AFAIK it is, then  
> > > you just need to develop a new reflex to use p.
> > 
> > Ah you said p, not puts, that's quite clever...  
> > LOL you are an eagle eye, but you are right of course.  
> > Robert  
> > And yes you can chose the f above 😉
> > 
> > > Regards, Morton
> > 
> > --  
> > You see things; and you say Why?  
> > But I dream things that never were; and I say Why not?  
> > -- George Bernard Shaw

---

<div class="post-metadata">

**Author:** ![Forum](https://avatars.discourse-cdn.com/v4/letter/f/43a26b/32.png) [@Forum](https://rubytalk.org/u/Forum)\
**Post date:** [19 June 2007 18:47 UTC](https://rubytalk.org/t/error-in-ancestor/38405/16 "2007-06-19T18:47:48Z")

</div>

Stupid me, sorry for the noise, here goes the public URL:

[http://talklikeaduck.denhaven2.com/articles/2007/04/23/ideas-for-improving-ruby](http://talklikeaduck.denhaven2.com/articles/2007/04/23/ideas-for-improving-ruby)

Cheers  
Robert

---

<div class="post-metadata">

**Author:** ![Rick\_DeNatale1](https://avatars.discourse-cdn.com/v4/letter/r/bbce88/32.png) [@Rick\_DeNatale1](https://rubytalk.org/u/Rick_DeNatale1)\
**Post date:** [21 June 2007 21:01 UTC](https://rubytalk.org/t/error-in-ancestor/38405/17 "2007-06-21T21:01:34Z")

</div>

Well David,

In short, NO.

Yesterday I was mulling over three or four topics to write about, your post  
tipped me over, so after a day of thought and editting the longish:

[http://talklikeaduck.denhaven2.com/articles/2007/06/21/where-i-come-from](http://talklikeaduck.denhaven2.com/articles/2007/06/21/where-i-come-from)

> **···**
>
> On 6/19/07, dblack@wobblini.net \<dblack@wobblini.net\> wrote:
> 
> > On Wed, 20 Jun 2007, Rick DeNatale wrote:
> 
> > \> Coming from a background in Smalltalk, my preference would be if this  
> > \> machinery were more visible and official, but Matz has his reasons for  
> > \> not doing so. For one thing, not documenting it, and hiding it from  
> > \> methods like ancestors and class makes it easier to tinker with as the  
> > \> language evolves without "officially" breaking backward compatibility.
> > 
> > Does that mean that no one who's ever used Smalltalk can ever think  
> > that it's right for Ruby to deviate from Smalltalk? 🙂
> 
> --  
> Rick DeNatale
> 
> My blog on Ruby  
> [http://talklikeaduck.denhaven2.com/](http://talklikeaduck.denhaven2.com/)

---

<div class="post-metadata">

**Author:** ![Morton\_Goldberg](https://avatars.discourse-cdn.com/v4/letter/m/7ea924/32.png) [@Morton\_Goldberg](https://rubytalk.org/u/Morton_Goldberg)\
**Post date:** [16 June 2007 23:53 UTC](https://rubytalk.org/t/error-in-ancestor/38405/18 "2007-06-16T23:53:14Z")

</div>

I admit that's more strictly accurate, but I find it very close to a distinction without a difference since I can't think of a case where (\<expression\>) doesn't evaluate to an object.

Regards, Morton

> **···**
>
> On Jun 16, 2007, at 6:37 PM, John Joyce wrote:
> 
> > Actually p is more like a short form for  
> > puts object.inspect

---

<div class="post-metadata">

**Author:** ![Rick\_DeNatale1](https://avatars.discourse-cdn.com/v4/letter/r/bbce88/32.png) [@Rick\_DeNatale1](https://rubytalk.org/u/Rick_DeNatale1)\
**Post date:** [20 June 2007 18:59 UTC](https://rubytalk.org/t/error-in-ancestor/38405/19 "2007-06-20T18:59:25Z")

</div>

Au contraire mon frere. Le défaut était le mien

For some reason something in my server config messed up the workings  
of ProxyPass reverse, and I was seeing the local hostname and port,  
and forgot to check when I cut and pasted from my browser.

Just a publically failed unit test. ;-(

> **···**
>
> On 6/19/07, Robert Dober \<robert.dober@gmail.com\> wrote:
> 
> > Stupid me, sorry for the noise, here goes the public URL:
> > 
> > [http://talklikeaduck.denhaven2.com/articles/2007/04/23/ideas-for-improving-ruby](http://talklikeaduck.denhaven2.com/articles/2007/04/23/ideas-for-improving-ruby)
> 
> --  
> Rick DeNatale
> 
> My blog on Ruby  
> [http://talklikeaduck.denhaven2.com/](http://talklikeaduck.denhaven2.com/)

---

<div class="post-metadata">

**Author:** ![David\_A\_Black3](https://avatars.discourse-cdn.com/v4/letter/d/6a8cbe/32.png) [@David\_A\_Black3](https://rubytalk.org/u/David_A_Black3)\
**Post date:** [21 June 2007 21:45 UTC](https://rubytalk.org/t/error-in-ancestor/38405/20 "2007-06-21T21:45:38Z")

</div>

Hi --

> > \> Coming from a background in Smalltalk, my preference would be if this  
> > \> machinery were more visible and official, but Matz has his reasons for  
> > \> not doing so. For one thing, not documenting it, and hiding it from  
> > \> methods like ancestors and class makes it easier to tinker with as the  
> > \> language evolves without "officially" breaking backward compatibility.
> > 
> > Does that mean that no one who's ever used Smalltalk can ever think  
> > that it's right for Ruby to deviate from Smalltalk? 🙂
> 
> Well David,
> 
> In short, NO.
> 
> Yesterday I was mulling over three or four topics to write about, your post  
> tipped me over, so after a day of thought and editting the longish:
> 
> [http://talklikeaduck.denhaven2.com/articles/2007/06/21/where-i-come-from](http://talklikeaduck.denhaven2.com/articles/2007/06/21/where-i-come-from)

Cool -- I'm glad. (BTW there's an unclosed emphasis tag or something,  
causing about the last 1/3 to be in bold.) The points at the end are  
especially interesting, about metaprogramming and such in Ruby as  
opposed to Smalltalk, and Alan Kay's comment "that he was disappointed  
that so few Smalltalkers experimented with changing and extending  
Smalltalk by building off of the mechanisms of Class, Metaclass, and  
Behavior." I've actually been, perhaps not disappointed but puzzled,  
at the form some of this activity takes -- or doesn't take -- in the  
Ruby world. In particular, the needle sometimes seems to be stuck in  
the groove of certain ways of looking at the matter of changing and/or  
amending the behavior of core-class objects. People are definitely  
interested, for example, in the idea of having a way to do  
block-scoped (or something-scoped) modifications to core classes; but  
I think I've literally never heard anyone report actually having used  
any of the libraries that let one do this. And in my opinion 'extend'  
is massively underutilized; it really could be the answer to almost  
every case of wanting to have, say, an Array that can shuffle itself,  
or whatever.

As for singleton classes: I still strongly root for  
Kernel#singleton\_class. I find that people understand the whole thing  
quite readily when it's explained to them that every object has (a) a  
"birth" class and (b) a class of its own where it can stash methods  
that only it can call. And it all falls into place except that you  
have to go through the class \<\< self; self; end thing to get at the  
class, and that makes it feel like a second-class (ha ha) citizen.  
(Hmmm... therein might lie another essay.... 🙂

David

> **···**
>
> On Fri, 22 Jun 2007, Rick DeNatale wrote:
> 
> > On 6/19/07, dblack@wobblini.net \<dblack@wobblini.net\> wrote:
> > 
> > > On Wed, 20 Jun 2007, Rick DeNatale wrote:
> 
> --  
> \* Books:  
> &nbsp;&nbsp;&nbsp;RAILS ROUTING (new! [http://www.awprofessional.com/title/0321509242\](http://www.awprofessional.com/title/0321509242%5C))  
> &nbsp;&nbsp;&nbsp;RUBY FOR RAILS ([http://www.manning.com/black\](http://www.manning.com/black%5C))  
> \* Ruby/Rails training  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& consulting: Ruby Power and Light, LLC ([http://www.rubypal.com](http://www.rubypal.com))

[Next page](https://rubytalk.org/t/error-in-ancestor/38405.md?page=2)
