[BUG] Ruby 1.9.0: possible bug when subclassing BasicObject

Discussion in 'Ruby' started by Michael Fellinger, Dec 27, 2007.

  1. 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
     
    Michael Fellinger, Dec 27, 2007
    #1
    1. Advertising

  2. On Dec 27, 2007 5:07 AM, Michael Fellinger <> 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/
     
    Rick DeNatale, Dec 27, 2007
    #2
    1. Advertising

  3. Michael Fellinger

    Xavier Noria Guest

    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
     
    Xavier Noria, Dec 27, 2007
    #3
  4. On Dec 28, 2007 12:52 AM, Xavier Noria <> 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
     
    Michael Fellinger, Dec 27, 2007
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Steve Holden
    Replies:
    1
    Views:
    402
    Behrang Dadsetan
    Jul 2, 2003
  2. Newbie
    Replies:
    2
    Views:
    90
    Luciano Ramalho
    Feb 13, 2007
  3. Intransition
    Replies:
    4
    Views:
    105
    Xavier Noria
    Aug 31, 2010
  4. Alexey Petrushin
    Replies:
    8
    Views:
    256
    Alexey Petrushin
    Mar 7, 2011
  5. Jeremy Henty
    Replies:
    10
    Views:
    264
    Uri Guttman
    Feb 22, 2007
Loading...

Share This Page