[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

[BUG] Ruby 1.9.0: possible bug when subclassing BasicObject

Michael Fellinger

12/27/2007 10:08:00 AM

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

Thanks in advance
^ manveru

3 Answers

Rick DeNatale

12/27/2007 3:10:00 PM

0

On Dec 27, 2007 5:07 AM, Michael Fellinger <m.fellinger@gmail.com> 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.ram...
>
> 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.denh...

Xavier Noria

12/27/2007 3:53:00 PM

0

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


Michael Fellinger

12/27/2007 4:05:00 PM

0

On Dec 28, 2007 12:52 AM, Xavier Noria <fxn@hashref.com> wrote:
> 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.

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

^ manveru