defining allocate is deprecated; use rb_define_alloc_func instead

B

Brian Takita

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
 
C

Charles Oliver Nutter

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
 

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

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top