Ruby 1.9.0: possible bug when subclassing BasicObject

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

Thanks in advance
^ manveru

On Dec 27, 2007 5:07 AM, Michael F. [email protected]
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

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/

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

On Dec 28, 2007 12:52 AM, Xavier N. [email protected] 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