* [ruby-core:103500] [Ruby master Bug#11230] Should rb_struct_s_members() be public API?
[not found] <redmine.issue-11230.20150606200632.772@ruby-lang.org>
@ 2021-04-17 17:06 ` merch-redmine
2023-01-17 21:37 ` [ruby-core:111864] " jeremyevans0 (Jeremy Evans) via ruby-core
2023-02-10 1:36 ` [ruby-core:112318] " mame (Yusuke Endoh) via ruby-core
2 siblings, 0 replies; 3+ messages in thread
From: merch-redmine @ 2021-04-17 17:06 UTC (permalink / raw)
To: ruby-core
Issue #11230 has been updated by jeremyevans0 (Jeremy Evans).
At the April 2021 developer meeting, it was decided to remove this C-API function after Ruby 3.2.
----------------------------------------
Bug #11230: Should rb_struct_s_members() be public API?
https://bugs.ruby-lang.org/issues/11230#change-91599
* Author: Eregon (Benoit Daloze)
* Status: Open
* Priority: Normal
* ruby -v: ruby 2.2.2p95 (2015-04-13 revision 50295) [x86_64-linux]
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN
----------------------------------------
rb_struct_s_members() is declared in include/ruby/intern.h.
However it seems this is a fairly internal API as it returns an hidden Array.
For instance, there was a try to specify the behavior in
https://github.com/rubinius/rubinius/commit/2642a30c57973987d2a7b7e85b3ce1e78100a31b
but that produces only erratic behavior on MRI because that usage is not intended.
A valid usage might be:
static VALUE get_struct_member(VALUE self, VALUE obj, VALUE i) {
return RARRAY_AREF(rb_struct_s_members(obj), NUM2INT(i));
}
p get_struct_member(Struct.new(:a, :bb), 1)
But do we need such access and is it worth exposing a potentially dangerous function like this?
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 3+ messages in thread
* [ruby-core:111864] [Ruby master Bug#11230] Should rb_struct_s_members() be public API?
[not found] <redmine.issue-11230.20150606200632.772@ruby-lang.org>
2021-04-17 17:06 ` [ruby-core:103500] [Ruby master Bug#11230] Should rb_struct_s_members() be public API? merch-redmine
@ 2023-01-17 21:37 ` jeremyevans0 (Jeremy Evans) via ruby-core
2023-02-10 1:36 ` [ruby-core:112318] " mame (Yusuke Endoh) via ruby-core
2 siblings, 0 replies; 3+ messages in thread
From: jeremyevans0 (Jeremy Evans) via ruby-core @ 2023-01-17 21:37 UTC (permalink / raw)
To: ruby-core; +Cc: jeremyevans0 (Jeremy Evans)
Issue #11230 has been updated by jeremyevans0 (Jeremy Evans).
I submitted a pull request to remove the prototype from the public header files: https://github.com/ruby/ruby/pull/7141
`rb_struct_s_members` is still an exported symbol as it is used internally by `marshal.c`.
One of reasons stated to remove this method is that it returns a hidden Array. However, `rb_struct_members` appears to return the same hidden Array (that method is also used internally by `marshal.c`). Should we consider removing `rb_struct_members` from the public API as well?
----------------------------------------
Bug #11230: Should rb_struct_s_members() be public API?
https://bugs.ruby-lang.org/issues/11230#change-101278
* Author: Eregon (Benoit Daloze)
* Status: Open
* Priority: Normal
* ruby -v: ruby 2.2.2p95 (2015-04-13 revision 50295) [x86_64-linux]
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN
----------------------------------------
rb_struct_s_members() is declared in include/ruby/intern.h.
However it seems this is a fairly internal API as it returns an hidden Array.
For instance, there was a try to specify the behavior in
https://github.com/rubinius/rubinius/commit/2642a30c57973987d2a7b7e85b3ce1e78100a31b
but that produces only erratic behavior on MRI because that usage is not intended.
A valid usage might be:
static VALUE get_struct_member(VALUE self, VALUE obj, VALUE i) {
return RARRAY_AREF(rb_struct_s_members(obj), NUM2INT(i));
}
p get_struct_member(Struct.new(:a, :bb), 1)
But do we need such access and is it worth exposing a potentially dangerous function like this?
--
https://bugs.ruby-lang.org/
______________________________________________
ruby-core mailing list -- ruby-core@ml.ruby-lang.org
To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/
^ permalink raw reply [flat|nested] 3+ messages in thread
* [ruby-core:112318] [Ruby master Bug#11230] Should rb_struct_s_members() be public API?
[not found] <redmine.issue-11230.20150606200632.772@ruby-lang.org>
2021-04-17 17:06 ` [ruby-core:103500] [Ruby master Bug#11230] Should rb_struct_s_members() be public API? merch-redmine
2023-01-17 21:37 ` [ruby-core:111864] " jeremyevans0 (Jeremy Evans) via ruby-core
@ 2023-02-10 1:36 ` mame (Yusuke Endoh) via ruby-core
2 siblings, 0 replies; 3+ messages in thread
From: mame (Yusuke Endoh) via ruby-core @ 2023-02-10 1:36 UTC (permalink / raw)
To: ruby-core; +Cc: mame (Yusuke Endoh)
Issue #11230 has been updated by mame (Yusuke Endoh).
Discussed at the dev meeting.
When we considered removing rb_struct_s_members two years ago, we did not find its use in a major gem. Therefore, we agreed to remove it once.
However, two years have passed since then, and now we have found that oj gem is using it.
```
$ gem-codesearch rb_struct_s_members | sort
...
2023-02-01 /srv/gems/oj-3.14.1/ext/oj/custom.c: ma = rb_struct_s_members(clas);
2023-02-01 /srv/gems/oj-3.14.1/ext/oj/dump_object.c: VALUE ma = rb_struct_s_members(clas);
2023-02-01 /srv/gems/oj-3.14.1/ext/oj/rails.c: ma = rb_struct_s_members(rb_obj_class(obj));
```
It's possible to fix oj gem and have a deprecation warning period. However, it would be easier to just keep this C API, unless there is a strong reason why we really have to remove it.
----------------------------------------
Bug #11230: Should rb_struct_s_members() be public API?
https://bugs.ruby-lang.org/issues/11230#change-101759
* Author: Eregon (Benoit Daloze)
* Status: Open
* Priority: Normal
* ruby -v: ruby 2.2.2p95 (2015-04-13 revision 50295) [x86_64-linux]
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN
----------------------------------------
rb_struct_s_members() is declared in include/ruby/intern.h.
However it seems this is a fairly internal API as it returns an hidden Array.
For instance, there was a try to specify the behavior in
https://github.com/rubinius/rubinius/commit/2642a30c57973987d2a7b7e85b3ce1e78100a31b
but that produces only erratic behavior on MRI because that usage is not intended.
A valid usage might be:
static VALUE get_struct_member(VALUE self, VALUE obj, VALUE i) {
return RARRAY_AREF(rb_struct_s_members(obj), NUM2INT(i));
}
p get_struct_member(Struct.new(:a, :bb), 1)
But do we need such access and is it worth exposing a potentially dangerous function like this?
--
https://bugs.ruby-lang.org/
______________________________________________
ruby-core mailing list -- ruby-core@ml.ruby-lang.org
To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-02-10 1:37 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <redmine.issue-11230.20150606200632.772@ruby-lang.org>
2021-04-17 17:06 ` [ruby-core:103500] [Ruby master Bug#11230] Should rb_struct_s_members() be public API? merch-redmine
2023-01-17 21:37 ` [ruby-core:111864] " jeremyevans0 (Jeremy Evans) via ruby-core
2023-02-10 1:36 ` [ruby-core:112318] " mame (Yusuke Endoh) via ruby-core
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).