defining allocate is deprecated; use rb_define_alloc_func instead

Discussion in 'Ruby' started by Brian Takita, Oct 31, 2010.

  1. Brian Takita

    Brian Takita Guest

    Hello, I'm trying to upgrade RR to Ruby 1.9.2.

    I'm getting the following warning:

    warning: defining StrongSpecFixture.allocate is deprecated; use
    rb_define_alloc_func()

    Is there a way to redefine allocate in Ruby in a way that works across
    all of the different Ruby implementations (JRuby, Rubinius, etc)?

    Thank you,
    Brian
     
    Brian Takita, Oct 31, 2010
    #1
    1. Advertising

  2. Re: defining allocate is deprecated; use rb_define_alloc_funcinstead

    On Sat, Oct 30, 2010 at 6:07 PM, Brian Takita <> wrote:
    > Hello, I'm trying to upgrade RR to Ruby 1.9.2.
    >
    > I'm getting the following warning:
    >
    > warning: defining StrongSpecFixture.allocate is deprecated; use
    > rb_define_alloc_func()
    >
    > Is there a way to redefine allocate in Ruby in a way that works across
    > all of the different Ruby implementations (JRuby, Rubinius, etc)?


    Not really. Most impls, including MRI and JRuby, don't actually
    dispatch to allocate when constructing a new object, so there's no way
    to replace it at runtime. This is done partially for performance
    reasons, and partially (at least in JRuby's case) because allocate
    initializes impossible-to-initialize-any-other-way internal state for
    the object, so replacing it would be a bad thing.

    JRuby 1.6 does provide a solid start on a compatible C API, though, so
    if it's native-level allocate binding you need, that's an option. And
    of course there's impl-specific ways to do this entirely from Ruby
    code in JRuby and probably others.

    - Charlie
     
    Charles Oliver Nutter, Nov 19, 2010
    #2
    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. Barney Barumba
    Replies:
    0
    Views:
    565
    Barney Barumba
    Jul 23, 2003
  2. johny smith
    Replies:
    8
    Views:
    421
    Peter Koch Larsen
    Jul 2, 2004
  3. Replies:
    0
    Views:
    436
  4. Charles Mills

    rb_define_alloc_func()

    Charles Mills, Jul 12, 2004, in forum: Ruby
    Replies:
    0
    Views:
    119
    Charles Mills
    Jul 12, 2004
  5. Replies:
    24
    Views:
    2,897
    Gene Wirchenko
    Jul 19, 2012
Loading...

Share This Page