[#106355] [Ruby master Bug#18373] RBS build failure: '/include/x86_64-linux/ruby/config.h', needed by 'constants.o'. — "vo.x (Vit Ondruch)" <noreply@...>
Issue #18373 has been reported by vo.x (Vit Ondruch).
28 messages
2021/12/01
[ruby-core:106413] [Ruby master Misc#17502] C vs Ruby
From:
"ko1 (Koichi Sasada)" <noreply@...>
Date:
2021-12-02 19:53:23 UTC
List:
ruby-core #106413
Issue #17502 has been updated by ko1 (Koichi Sasada).
> 1) be accessible to C extensions
I think it is better but not sure we can.
> 2) can't be re-written any faster in pseuso-C in Ruby
Do you mean Cython for Python?
> 3) has an easy way to define keyword parameters?
I believe the easiest way to write keywords is written in Ruby.
> I feel C code in the middle of Ruby code is not so great, and if moving C code to strings in Ruby is just to add Primitive.attr! 'inline' (like for Float#zero?),
For me, for few lines I'm fine to mix Ruby and C.
----------------------------------------
Misc #17502: C vs Ruby
https://bugs.ruby-lang.org/issues/17502#change-95053
* Author: marcandre (Marc-Andre Lafortune)
* Status: Open
* Priority: Normal
* Assignee: ko1 (Koichi Sasada)
----------------------------------------
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.
```diff
-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:
1) be accessible to C extensions
2) can't be re-written any faster in pseuso-C in Ruby
3) 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.
```ruby
Ractor.method(:yield).parameters
# => [[:req, :obj], [:key, :move]] # good!
Fiber.method(:initialize).parameters
# => [[:rest]] # not good, should be [[:key, :blocking]]
```
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>