Issue #19261 has been updated by fabiormoura (Fabio Moura Maia).
File data-and-struct-remove-members-method.patch added
k0kubun (Takashi Kokubun) wrote in #note-2:
If we were to remove this from Data instances, I'd
like Struct instances to not have that method either for consistency. Let's say you
replace Struct.new with Data.define for something that's already immutable, I
don't want that change to break anything. But `Data` randomly lacking some shorthand
methods that exist for Struct would make such refactoring harder.
I'm a newbie at ruby's codebase, but this sounds a reasonable suggestion so,
I've attached a revised patch with the requested modifications. Both test suites for
Data (test_data.rb) and Struct (test_struct.rb) passed.
```
build % make test-all TESTS=ruby/test_struct.rb
Run options:
--seed=7424
"--ruby=./miniruby -I../ruby/lib -I. -I.ext/common ../ruby/tool/runruby.rb
--extout=.ext -- --disable-gems"
--excludes-dir=../ruby/test/excludes
--name=!/memory_leak/
# Running tests:
Finished tests in 0.037040s, 2591.7927 tests/s, 14848.8121 assertions/s.
96 tests, 550 assertions, 0 failures, 0 errors, 0 skips
ruby -v: ruby 3.3.0dev (2023-01-08T15:02:29Z master 8f6a9ad35d) [x86_64-darwin21]
build % make test-all TESTS=ruby/test_data.rb
Run options:
--seed=63192
"--ruby=./miniruby -I../ruby/lib -I. -I.ext/common ../ruby/tool/runruby.rb
--extout=.ext -- --disable-gems"
--excludes-dir=../ruby/test/excludes
--name=!/memory_leak/
# Running tests:
Finished tests in 0.008879s, 1464.1288 tests/s, 12726.6584 assertions/s.
13 tests, 113 assertions, 0 failures, 0 errors, 0 skips
ruby -v: ruby 3.3.0dev (2023-01-08T15:02:29Z master 8f6a9ad35d) [x86_64-darwin21]
```
----------------------------------------
Feature #19261: `Data#members` is not important
https://bugs.ruby-lang.org/issues/19261#change-101160
* Author: ko1 (Koichi Sasada)
* Status: Open
* Priority: Normal
----------------------------------------
`Data#members` is defined but it is calculated by `self.class.members` (in other words,
`#members` is a shorthand for `self.class.members`).
So it is better to remove this method.
```ruby
P = Data.define(:x, :y)
p P.new(1, 2).members #=> [:x, :y]
Group = Data.define(:name, :members)
gs = Group.new('SasadaFamily', %w(ko1 yuki))
p gs.members #=> ["ko1", "yuki"]
```
---Files--------------------------------
data-members-remove-method.patch (1.87 KB)
data-and-struct-remove-members-method.patch (3.5 KB)
--
https://bugs.ruby-lang.org/