Actions
Misc #17502
openC vs Ruby
Status:
Assigned
Assignee:
Description
Some features are coded in a mix of Ruby and C (e.g. ractor.rb).
External gems don't have access to this. The C-API to deal with keyword parameters is also very verbose the parsing and the engine does not know it.
Moreover, some optimization PRs are simply rewriting C-code into Ruby using pseudo C code.
I understand the intentions are great, but changes like https://github.com/ruby/ruby/pull/4018/files seem a symptom that something needs to be improved with the C api.
-static VALUE
- flo_zero_p(VALUE num)
- {
- return flo_iszero(num) ? Qtrue : Qfalse;
- }
# in different file:
+ def zero?
+ Primitive.attr! 'inline'
+ Primitive.cexpr! 'flo_iszero(self) ? Qtrue : Qfalse'
+ end
It seems to me that this is a way to circumvent a deeper issue. Is this the right direction?
Is there a plan for an API that would:
- be accessible to C extensions
- can't be re-written any faster in pseuso-C in Ruby
- has an easy way to define keyword parameters?
I realize that RBS may give perfect signatures, but ideally parameters
would be more informative for C-functions too.
Ractor.method(:yield).parameters
# => [[:req, :obj], [:key, :move]] # good!
Fiber.method(:initialize).parameters
# => [[:rest]] # not good, should be [[:key, :blocking]]
Actions
Like0
Like0Like0Like0Like0Like0