[#104169] [Ruby master Feature#17938] Keyword alternative for boolean positional arguments — matheusrichardt@...

Issue #17938 has been reported by matheusrich (Matheus Richard).

12 messages 2021/06/04

[#104213] [Ruby master Feature#17942] Add a `initialize(public @a, private @b)` shortcut syntax for defining public/private accessors for instance vars — tyler@...

SXNzdWUgIzE3OTQyIGhhcyBiZWVuIHJlcG9ydGVkIGJ5IFR5bGVyUmljayAoVHlsZXIgUmljayku

6 messages 2021/06/09

[#104288] [Ruby master Bug#17992] Upstreaming the htmlentities gem into CGI#.(un)escape_html — alexandermomchilov@...

Issue #17992 has been reported by AMomchilov (Alexander Momchilov).

9 messages 2021/06/15

[#104338] [Ruby master Misc#17997] DevelopersMeeting20210715Japan — mame@...

Issue #17997 has been reported by mame (Yusuke Endoh).

10 messages 2021/06/17

[#104361] [Ruby master Bug#18000] have_library doesn't work when ruby is compiled with --disable-shared --disable-install-static-library — jean.boussier@...

Issue #18000 has been reported by byroot (Jean Boussier).

9 messages 2021/06/18

[#104381] [Ruby master Feature#18004] Add Async to the stdlib — shannonskipper@...

Issue #18004 has been reported by shan (Shannon Skipper).

9 messages 2021/06/22

[#104401] [Ruby master Feature#18007] Help developers of C extensions meet requirements in "doc/extension.rdoc" — mike.dalessio@...

Issue #18007 has been reported by mdalessio (Mike Dalessio).

16 messages 2021/06/25

[#104430] [Ruby master Bug#18011] `Method#parameters` is incorrect for forwarded arguments — josh.cheek@...

Issue #18011 has been reported by josh.cheek (Josh Cheek).

12 messages 2021/06/29

[ruby-core:104173] [Ruby master Misc#17502] C vs Ruby

From: eregontp@...
Date: 2021-06-05 09:21:04 UTC
List: ruby-core #104173
Issue #17502 has been updated by Eregon (Benoit Daloze).


@ko1 Could you reply to this?

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?`),
it seems much simpler and nicer to add `rb_impl_define_method_inline()` or so (private API, not public C API of course).

For instance, there is no syntax highlighting for C code in Ruby code (`Primitive.cexpr! 'flo_iszero(self) ? Qtrue : Qfalse'`), looking at callers of flo_iszero() would only reveal generated code, not the `Primitive.cexpr!`, etc.

----------------------------------------
Misc #17502: C vs Ruby
https://bugs.ruby-lang.org/issues/17502#change-92350

* 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>

In This Thread