As shown in the code snippet below, it is impossible to call Fiber.yield in case it is invoked (either directly or indirectly) via #initialize.
My understanding is that this is because #new method (which calls #initialize) is implemented in C.
Is there any chance that this restriction will be raised, for example by making changes so that #initialize will be called right after returning from the C function that implements #new?
class T1
def foo
Fiber.yield "hello from T1#foo"
end
end
class T2
def initialize
Fiber.yield "hello from T2#initialize"
end
end
f = Fiber.new do
T1.new.foo
end
puts f.resume # says "hello"
f = Fiber.new do
T2.new
end
puts f.resume # can't cross C function boundary error
The text was updated successfully, but these errors were encountered:
It's because #initialize is called via mrb_funcall(). We can solve this by implementing Class#new in Ruby, but when I tried before it slows down mruby significantly. If this issue is not critical, I'd like to declare this as a mruby limitation.
As shown in the code snippet below, it is impossible to call
Fiber.yield
in case it is invoked (either directly or indirectly) via#initialize
.My understanding is that this is because
#new
method (which calls#initialize
) is implemented in C.Is there any chance that this restriction will be raised, for example by making changes so that
#initialize
will be called right after returning from the C function that implements#new
?The text was updated successfully, but these errors were encountered: