# Ruby 1.9.0: possible bug when subclassing BasicObject

**URL:** <https://www.ruby-forum.com/t/ruby-1-9-0-possible-bug-when-subclassing-basicobject/124288>\
**Category:** Ruby\
**Created:** [December 27, 2007, 11:10am UTC](https://www.ruby-forum.com/t/ruby-1-9-0-possible-bug-when-subclassing-basicobject/124288 "2007-12-27T11:10:26Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mifi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/7993a0/32.png) [@mifi](https://www.ruby-forum.com/u/mifi)\
**Post date:** [December 27, 2007, 11:10am UTC](https://www.ruby-forum.com/t/ruby-1-9-0-possible-bug-when-subclassing-basicobject/124288/1 "2007-12-27T11:10:26Z")

</div>

I noticed a problem with constant lookup in Ruby 1.9.0 when  
subclassing from BasicObject, would anyone please explain this  
behavior to me, otherwise I’ll go and file a bug.

What fails: [http://p.ramaze.net/23](http://p.ramaze.net/23)

Thanks in advance  
^ manveru

---

<div class="post-metadata">

**Author:** ![mifi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/7993a0/32.png) [@mifi](https://www.ruby-forum.com/u/mifi)\
**Post date:** [December 27, 2007, 4:12pm UTC](https://www.ruby-forum.com/t/ruby-1-9-0-possible-bug-when-subclassing-basicobject/124288/2 "2007-12-27T16:12:01Z")

</div>

On Dec 27, 2007 5:07 AM, Michael F. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> I noticed a problem with constant lookup in Ruby 1.9.0 when  
> subclassing from BasicObject, would anyone please explain this  
> behavior to me, otherwise I’ll go and file a bug.
> 
> What fails: [http://p.ramaze.net/23](http://p.ramaze.net/23)
> 
> Thanks in advance  
> ^ manveru

It seems to me that this is the way it should work.

BasicObject is intended to impose the minimum implementation for use  
by things like proxies. Leaving the namespace as empty as possible  
seems to me to be a good thing. And as your example points out you  
can get at things in the global namespace by explicitly using the ::  
prefix.

–  
Rick DeNatale

My blog on Ruby  
[http://talklikeaduck.denhaven2.com/](http://talklikeaduck.denhaven2.com/)

---

<div class="post-metadata">

**Author:** ![mifi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/7993a0/32.png) [@mifi](https://www.ruby-forum.com/u/mifi)\
**Post date:** [December 27, 2007, 4:54pm UTC](https://www.ruby-forum.com/t/ruby-1-9-0-possible-bug-when-subclassing-basicobject/124288/3 "2007-12-27T16:54:54Z")

</div>

On Dec 27, 2007, at 4:10 PM, Rick DeNatale wrote:

> BasicObject is intended to impose the minimum implementation for use  
> by things like proxies. Leaving the namespace as empty as possible  
> seems to me to be a good thing. And as your example points out you  
> can get at things in the global namespace by explicitly using the ::  
> prefix.

I think it is a mere consequence of BasicObject not being an Object  
(BasicObject is the new root class). As you know Object is still the  
class where top-level constants are stored, so subclasses of  
BasicObject knows nothing about top-level constants.

That affects top-level methods as well, for example you can’t even  
call puts or raise directly from within a BasicObject.

– fxn

---

<div class="post-metadata">

**Author:** ![mifi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/7993a0/32.png) [@mifi](https://www.ruby-forum.com/u/mifi)\
**Post date:** [December 27, 2007, 5:06pm UTC](https://www.ruby-forum.com/t/ruby-1-9-0-possible-bug-when-subclassing-basicobject/124288/4 "2007-12-27T17:06:07Z")

</div>

On Dec 28, 2007 12:52 AM, Xavier N. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> class where top-level constants are stored, so subclasses of  
> BasicObject knows nothing about top-level constants.
> 
> That affects top-level methods as well, for example you can’t even  
> call puts or raise directly from within a BasicObject.

Thank you very much, that’s what i suspected. Quite useful actually.

^ manveru
