Thanks for your answer! I also asked the question as an issue on the mruby repo and got an answer about using the C macros. My code works, now.
My use-case for allocating an object in a function that isn't a constructor was not to allocate more memory for "self", but to allocate a new object. Imagine the following code:
class Foo
...
end
class Bar
...
def do_something
...
return Foo.new
end
end
Now imagine Foo and Bar are actually not defined in Ruby but in C, and do_something is a C function, you would need to create an instance of Foo from inside a C function.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Thanks for your answer! I also asked the question as an issue on the mruby repo and got an answer about using the C macros. My code works, now.
My use-case for allocating an object in a function that isn't a constructor was not to allocate more memory for "self", but to allocate a new object. Imagine the following code:
class Foo
...
end
class Bar
...
def do_something
...
return Foo.new
end
end
Now imagine Foo and Bar are actually not defined in Ruby but in C, and do_something is a C function, you would need to create an instance of Foo from inside a C function.