[BUG] Ruby 1.9.0: possible bug when subclassing BasicObject

M

Michael Fellinger

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
 
R

Rick DeNatale

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.
 
X

Xavier Noria

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
 
M

Michael Fellinger

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.

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

^ manveru
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top