[#84867] [Ruby trunk Bug#14357] thread_safe tests suite segfaults — v.ondruch@...

Issue #14357 has been reported by vo.x (Vit Ondruch).

11 messages 2018/01/15

[#84980] [Ruby trunk Feature#13618][Assigned] [PATCH] auto fiber schedule for rb_wait_for_single_fd and rb_waitpid — hsbt@...

Issue #13618 has been updated by hsbt (Hiroshi SHIBATA).

10 messages 2018/01/23
[#85012] Re: [Ruby trunk Feature#13618][Assigned] [PATCH] auto fiber schedule for rb_wait_for_single_fd and rb_waitpid — Eric Wong <normalperson@...> 2018/01/23

hsbt@ruby-lang.org wrote:

[ruby-core:84694] [Ruby trunk Feature#14332] Module.used_refinements to list refinement modules

From: eregontp@...
Date: 2018-01-07 23:31:10 UTC
List: ruby-core #84694
Issue #14332 has been reported by Eregon (Benoit Daloze).

----------------------------------------
Feature #14332: Module.used_refinements to list refinement modules
https://bugs.ruby-lang.org/issues/14332

* Author: Eregon (Benoit Daloze)
* Status: Open
* Priority: Normal
* Assignee: shugo (Shugo Maeda)
* Target version: 2.6
----------------------------------------
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/

Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>

In This Thread

Prev Next