* [ruby-core:105746] [Ruby master Feature#14332] Module.used_refinements to list refinement modules
[not found] <redmine.issue-14332.20180107233109.772@ruby-lang.org>
@ 2021-10-22 5:18 ` shugo (Shugo Maeda)
2021-11-19 2:14 ` [ruby-core:106166] " shugo (Shugo Maeda)
` (5 subsequent siblings)
6 siblings, 0 replies; 7+ messages in thread
From: shugo (Shugo Maeda) @ 2021-10-22 5:18 UTC (permalink / raw)
To: ruby-core
Issue #14332 has been updated by shugo (Shugo Maeda).
Assignee changed from shugo (Shugo Maeda) to matz (Yukihiro Matsumoto)
Matz, can I add Module.used_refinements?
----------------------------------------
Feature #14332: Module.used_refinements to list refinement modules
https://bugs.ruby-lang.org/issues/14332#change-94250
* Author: Eregon (Benoit Daloze)
* Status: Assigned
* Priority: Normal
* Assignee: matz (Yukihiro Matsumoto)
----------------------------------------
Module.used_modules was added in #7418.
But I think `Module.used_refinements` is more useful or at least complementary.
Refinements were implemented in TruffleRuby, and I found Module.used_refinements so useful that I left it there.
Instead of listing namespace modules (arguments to #using), it lists the refinement modules:
~~~ ruby
module Json
refine Integer do
def to_json
to_s
end
end
refine String do
def to_json
inspect
end
end
end
module Fact
refine Integer do
def fact
self <= 1 ? 1 : self * (self-1).fact
end
end
end
using Json
p Module.used_modules # => [Json]
p Module.used_refinements # => [#<refinement:Integer@Json>, #<refinement:String@Json>]
using Fact
p Module.used_modules # => [Json, Fact]
p Module.used_refinements # => [#<refinement:Integer@Fact>, #<refinement:Integer@Json>, #<refinement:String@Json>]
~~~
This shows which classes are refined and by which refinement namespace.
It also shows if a class has multiple active refinements in the scope.
And, last but not least, the name of the method is contains "refinements".
I find `used_modules` hard to remember and it doesn't sound related to refinements from the name (while looking at the Module's methods).
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 7+ messages in thread
* [ruby-core:106166] [Ruby master Feature#14332] Module.used_refinements to list refinement modules
[not found] <redmine.issue-14332.20180107233109.772@ruby-lang.org>
2021-10-22 5:18 ` [ruby-core:105746] [Ruby master Feature#14332] Module.used_refinements to list refinement modules shugo (Shugo Maeda)
@ 2021-11-19 2:14 ` shugo (Shugo Maeda)
2021-11-19 20:23 ` [ruby-core:106181] " Eregon (Benoit Daloze)
` (4 subsequent siblings)
6 siblings, 0 replies; 7+ messages in thread
From: shugo (Shugo Maeda) @ 2021-11-19 2:14 UTC (permalink / raw)
To: ruby-core
Issue #14332 has been updated by shugo (Shugo Maeda).
Matz accepted Module.used_refinements at the developers meeting on 2021-11-18.
But we need to consider consistency of the return value with #12737, used_refinements will be introduced after #12737 is accepted (maybe in Ruby 3.2?).
----------------------------------------
Feature #14332: Module.used_refinements to list refinement modules
https://bugs.ruby-lang.org/issues/14332#change-94769
* Author: Eregon (Benoit Daloze)
* Status: Assigned
* Priority: Normal
* Assignee: matz (Yukihiro Matsumoto)
----------------------------------------
Module.used_modules was added in #7418.
But I think `Module.used_refinements` is more useful or at least complementary.
Refinements were implemented in TruffleRuby, and I found Module.used_refinements so useful that I left it there.
Instead of listing namespace modules (arguments to #using), it lists the refinement modules:
~~~ ruby
module Json
refine Integer do
def to_json
to_s
end
end
refine String do
def to_json
inspect
end
end
end
module Fact
refine Integer do
def fact
self <= 1 ? 1 : self * (self-1).fact
end
end
end
using Json
p Module.used_modules # => [Json]
p Module.used_refinements # => [#<refinement:Integer@Json>, #<refinement:String@Json>]
using Fact
p Module.used_modules # => [Json, Fact]
p Module.used_refinements # => [#<refinement:Integer@Fact>, #<refinement:Integer@Json>, #<refinement:String@Json>]
~~~
This shows which classes are refined and by which refinement namespace.
It also shows if a class has multiple active refinements in the scope.
And, last but not least, the name of the method contains "refinements".
I find `used_modules` hard to remember and it doesn't sound related to refinements from the name (while looking at the Module's methods).
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 7+ messages in thread
* [ruby-core:106181] [Ruby master Feature#14332] Module.used_refinements to list refinement modules
[not found] <redmine.issue-14332.20180107233109.772@ruby-lang.org>
2021-10-22 5:18 ` [ruby-core:105746] [Ruby master Feature#14332] Module.used_refinements to list refinement modules shugo (Shugo Maeda)
2021-11-19 2:14 ` [ruby-core:106166] " shugo (Shugo Maeda)
@ 2021-11-19 20:23 ` Eregon (Benoit Daloze)
2021-11-19 23:38 ` [ruby-core:106185] " shugo (Shugo Maeda)
` (3 subsequent siblings)
6 siblings, 0 replies; 7+ messages in thread
From: Eregon (Benoit Daloze) @ 2021-11-19 20:23 UTC (permalink / raw)
To: ruby-core
Issue #14332 has been updated by Eregon (Benoit Daloze).
For Module.used_refinements, I believe it has to be an Array, not a Hash.
We can see in the description:
```ruby
p Module.used_refinements # => [#<refinement:Integer@Fact>, #<refinement:Integer@Json>, #<refinement:String@Json>]
```
The refined classes are not unique, so we can't key by refined class.
And the order matters, so a `Hash[namespace => [refined classes]]` would be bad and needlessly complicated.
Since the spec of `Module.used_refinements` seems clear, I suggest to add it soon.
----------------------------------------
Feature #14332: Module.used_refinements to list refinement modules
https://bugs.ruby-lang.org/issues/14332#change-94789
* Author: Eregon (Benoit Daloze)
* Status: Assigned
* Priority: Normal
* Assignee: matz (Yukihiro Matsumoto)
----------------------------------------
Module.used_modules was added in #7418.
But I think `Module.used_refinements` is more useful or at least complementary.
Refinements were implemented in TruffleRuby, and I found Module.used_refinements so useful that I left it there.
Instead of listing namespace modules (arguments to #using), it lists the refinement modules:
~~~ ruby
module Json
refine Integer do
def to_json
to_s
end
end
refine String do
def to_json
inspect
end
end
end
module Fact
refine Integer do
def fact
self <= 1 ? 1 : self * (self-1).fact
end
end
end
using Json
p Module.used_modules # => [Json]
p Module.used_refinements # => [#<refinement:Integer@Json>, #<refinement:String@Json>]
using Fact
p Module.used_modules # => [Json, Fact]
p Module.used_refinements # => [#<refinement:Integer@Fact>, #<refinement:Integer@Json>, #<refinement:String@Json>]
~~~
This shows which classes are refined and by which refinement namespace.
It also shows if a class has multiple active refinements in the scope.
And, last but not least, the name of the method contains "refinements".
I find `used_modules` hard to remember and it doesn't sound related to refinements from the name (while looking at the Module's methods).
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 7+ messages in thread
* [ruby-core:106185] [Ruby master Feature#14332] Module.used_refinements to list refinement modules
[not found] <redmine.issue-14332.20180107233109.772@ruby-lang.org>
` (2 preceding siblings ...)
2021-11-19 20:23 ` [ruby-core:106181] " Eregon (Benoit Daloze)
@ 2021-11-19 23:38 ` shugo (Shugo Maeda)
2021-12-09 7:15 ` [ruby-core:106572] " matz (Yukihiro Matsumoto)
` (2 subsequent siblings)
6 siblings, 0 replies; 7+ messages in thread
From: shugo (Shugo Maeda) @ 2021-11-19 23:38 UTC (permalink / raw)
To: ruby-core
Issue #14332 has been updated by shugo (Shugo Maeda).
Eregon (Benoit Daloze) wrote in #note-7:
> For Module.used_refinements, I believe it has to be an Array, not a Hash.
> We can see in the description:
> ```ruby
> p Module.used_refinements # => [#<refinement:Integer@Fact>, #<refinement:Integer@Json>, #<refinement:String@Json>]
> ```
> The refined classes are not unique, so we can't key by refined class.
> And the order matters, so a `Hash[namespace => [refined classes]]` would be bad and needlessly complicated.
Agreed.
> Since the spec of `Module.used_refinements` seems clear, I suggest to add it soon.
Matz, what do you think of it?
https://github.com/shugo/ruby/compare/used_refinements
----------------------------------------
Feature #14332: Module.used_refinements to list refinement modules
https://bugs.ruby-lang.org/issues/14332#change-94793
* Author: Eregon (Benoit Daloze)
* Status: Assigned
* Priority: Normal
* Assignee: matz (Yukihiro Matsumoto)
----------------------------------------
Module.used_modules was added in #7418.
But I think `Module.used_refinements` is more useful or at least complementary.
Refinements were implemented in TruffleRuby, and I found Module.used_refinements so useful that I left it there.
Instead of listing namespace modules (arguments to #using), it lists the refinement modules:
~~~ ruby
module Json
refine Integer do
def to_json
to_s
end
end
refine String do
def to_json
inspect
end
end
end
module Fact
refine Integer do
def fact
self <= 1 ? 1 : self * (self-1).fact
end
end
end
using Json
p Module.used_modules # => [Json]
p Module.used_refinements # => [#<refinement:Integer@Json>, #<refinement:String@Json>]
using Fact
p Module.used_modules # => [Json, Fact]
p Module.used_refinements # => [#<refinement:Integer@Fact>, #<refinement:Integer@Json>, #<refinement:String@Json>]
~~~
This shows which classes are refined and by which refinement namespace.
It also shows if a class has multiple active refinements in the scope.
And, last but not least, the name of the method contains "refinements".
I find `used_modules` hard to remember and it doesn't sound related to refinements from the name (while looking at the Module's methods).
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 7+ messages in thread
* [ruby-core:106572] [Ruby master Feature#14332] Module.used_refinements to list refinement modules
[not found] <redmine.issue-14332.20180107233109.772@ruby-lang.org>
` (3 preceding siblings ...)
2021-11-19 23:38 ` [ruby-core:106185] " shugo (Shugo Maeda)
@ 2021-12-09 7:15 ` matz (Yukihiro Matsumoto)
2021-12-10 1:48 ` [ruby-core:106611] " shugo (Shugo Maeda)
2022-01-05 8:07 ` [ruby-core:106970] " shugo (Shugo Maeda)
6 siblings, 0 replies; 7+ messages in thread
From: matz (Yukihiro Matsumoto) @ 2021-12-09 7:15 UTC (permalink / raw)
To: ruby-core
Issue #14332 has been updated by matz (Yukihiro Matsumoto).
It's too late for 3.1. But after the release, I basically honor @shugo's decision here.
Matz.
----------------------------------------
Feature #14332: Module.used_refinements to list refinement modules
https://bugs.ruby-lang.org/issues/14332#change-95234
* Author: Eregon (Benoit Daloze)
* Status: Assigned
* Priority: Normal
* Assignee: matz (Yukihiro Matsumoto)
----------------------------------------
Module.used_modules was added in #7418.
But I think `Module.used_refinements` is more useful or at least complementary.
Refinements were implemented in TruffleRuby, and I found Module.used_refinements so useful that I left it there.
Instead of listing namespace modules (arguments to #using), it lists the refinement modules:
~~~ ruby
module Json
refine Integer do
def to_json
to_s
end
end
refine String do
def to_json
inspect
end
end
end
module Fact
refine Integer do
def fact
self <= 1 ? 1 : self * (self-1).fact
end
end
end
using Json
p Module.used_modules # => [Json]
p Module.used_refinements # => [#<refinement:Integer@Json>, #<refinement:String@Json>]
using Fact
p Module.used_modules # => [Json, Fact]
p Module.used_refinements # => [#<refinement:Integer@Fact>, #<refinement:Integer@Json>, #<refinement:String@Json>]
~~~
This shows which classes are refined and by which refinement namespace.
It also shows if a class has multiple active refinements in the scope.
And, last but not least, the name of the method contains "refinements".
I find `used_modules` hard to remember and it doesn't sound related to refinements from the name (while looking at the Module's methods).
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 7+ messages in thread
* [ruby-core:106611] [Ruby master Feature#14332] Module.used_refinements to list refinement modules
[not found] <redmine.issue-14332.20180107233109.772@ruby-lang.org>
` (4 preceding siblings ...)
2021-12-09 7:15 ` [ruby-core:106572] " matz (Yukihiro Matsumoto)
@ 2021-12-10 1:48 ` shugo (Shugo Maeda)
2022-01-05 8:07 ` [ruby-core:106970] " shugo (Shugo Maeda)
6 siblings, 0 replies; 7+ messages in thread
From: shugo (Shugo Maeda) @ 2021-12-10 1:48 UTC (permalink / raw)
To: ruby-core
Issue #14332 has been updated by shugo (Shugo Maeda).
Assignee changed from matz (Yukihiro Matsumoto) to shugo (Shugo Maeda)
----------------------------------------
Feature #14332: Module.used_refinements to list refinement modules
https://bugs.ruby-lang.org/issues/14332#change-95280
* Author: Eregon (Benoit Daloze)
* Status: Assigned
* Priority: Normal
* Assignee: shugo (Shugo Maeda)
----------------------------------------
Module.used_modules was added in #7418.
But I think `Module.used_refinements` is more useful or at least complementary.
Refinements were implemented in TruffleRuby, and I found Module.used_refinements so useful that I left it there.
Instead of listing namespace modules (arguments to #using), it lists the refinement modules:
~~~ ruby
module Json
refine Integer do
def to_json
to_s
end
end
refine String do
def to_json
inspect
end
end
end
module Fact
refine Integer do
def fact
self <= 1 ? 1 : self * (self-1).fact
end
end
end
using Json
p Module.used_modules # => [Json]
p Module.used_refinements # => [#<refinement:Integer@Json>, #<refinement:String@Json>]
using Fact
p Module.used_modules # => [Json, Fact]
p Module.used_refinements # => [#<refinement:Integer@Fact>, #<refinement:Integer@Json>, #<refinement:String@Json>]
~~~
This shows which classes are refined and by which refinement namespace.
It also shows if a class has multiple active refinements in the scope.
And, last but not least, the name of the method contains "refinements".
I find `used_modules` hard to remember and it doesn't sound related to refinements from the name (while looking at the Module's methods).
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 7+ messages in thread
* [ruby-core:106970] [Ruby master Feature#14332] Module.used_refinements to list refinement modules
[not found] <redmine.issue-14332.20180107233109.772@ruby-lang.org>
` (5 preceding siblings ...)
2021-12-10 1:48 ` [ruby-core:106611] " shugo (Shugo Maeda)
@ 2022-01-05 8:07 ` shugo (Shugo Maeda)
6 siblings, 0 replies; 7+ messages in thread
From: shugo (Shugo Maeda) @ 2022-01-05 8:07 UTC (permalink / raw)
To: ruby-core
Issue #14332 has been updated by shugo (Shugo Maeda).
Status changed from Assigned to Closed
Applied in commit:git|21ee5341f8fc4ca513295dff2148f7c203c908a7.
----------------------------------------
Feature #14332: Module.used_refinements to list refinement modules
https://bugs.ruby-lang.org/issues/14332#change-95798
* Author: Eregon (Benoit Daloze)
* Status: Closed
* Priority: Normal
* Assignee: shugo (Shugo Maeda)
----------------------------------------
Module.used_modules was added in #7418.
But I think `Module.used_refinements` is more useful or at least complementary.
Refinements were implemented in TruffleRuby, and I found Module.used_refinements so useful that I left it there.
Instead of listing namespace modules (arguments to #using), it lists the refinement modules:
~~~ ruby
module Json
refine Integer do
def to_json
to_s
end
end
refine String do
def to_json
inspect
end
end
end
module Fact
refine Integer do
def fact
self <= 1 ? 1 : self * (self-1).fact
end
end
end
using Json
p Module.used_modules # => [Json]
p Module.used_refinements # => [#<refinement:Integer@Json>, #<refinement:String@Json>]
using Fact
p Module.used_modules # => [Json, Fact]
p Module.used_refinements # => [#<refinement:Integer@Fact>, #<refinement:Integer@Json>, #<refinement:String@Json>]
~~~
This shows which classes are refined and by which refinement namespace.
It also shows if a class has multiple active refinements in the scope.
And, last but not least, the name of the method contains "refinements".
I find `used_modules` hard to remember and it doesn't sound related to refinements from the name (while looking at the Module's methods).
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2022-01-05 8:07 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <redmine.issue-14332.20180107233109.772@ruby-lang.org>
2021-10-22 5:18 ` [ruby-core:105746] [Ruby master Feature#14332] Module.used_refinements to list refinement modules shugo (Shugo Maeda)
2021-11-19 2:14 ` [ruby-core:106166] " shugo (Shugo Maeda)
2021-11-19 20:23 ` [ruby-core:106181] " Eregon (Benoit Daloze)
2021-11-19 23:38 ` [ruby-core:106185] " shugo (Shugo Maeda)
2021-12-09 7:15 ` [ruby-core:106572] " matz (Yukihiro Matsumoto)
2021-12-10 1:48 ` [ruby-core:106611] " shugo (Shugo Maeda)
2022-01-05 8:07 ` [ruby-core:106970] " shugo (Shugo Maeda)
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).