[#82311] [Ruby trunk Bug#13794] Infinite loop of sched_yield — charlie@...
Issue #13794 has been reported by catphish (Charlie Smurthwaite).
4 messages
2017/08/09
[#82518] [Ruby trunk Feature#13618] [PATCH] auto fiber schedule for rb_wait_for_single_fd and rb_waitpid — mame@...
Issue #13618 has been updated by mame (Yusuke Endoh).
5 messages
2017/08/30
[#82552] Re: [Ruby trunk Feature#13618] [PATCH] auto fiber schedule for rb_wait_for_single_fd and rb_waitpid
— Eric Wong <normalperson@...>
2017/08/31
mame@ruby-lang.org wrote:
[#82756] Re: [Ruby trunk Feature#13618] [PATCH] auto fiber schedule for rb_wait_for_single_fd and rb_waitpid
— Eric Wrong <normalperson@...>
2017/09/12
Eric Wrong <normalperson@yhbt.net> wrote:
[ruby-core:82371] [Ruby trunk Feature#13805] Make refinement scoping to be like that of constants
From:
tom@...
Date:
2017-08-13 22:52:53 UTC
List:
ruby-core #82371
Issue #13805 has been updated by wardrop (Tom Wardrop).
jeremyevans0 (Jeremy Evans) wrote:
> You probably want to read the very long issue that introduced refinements (#4085), which contains the reasoning.
I thought there'd be one of these long discussions floating around, thanks for the links. Didn't find a lot of discussion on why refinements weren't implemented as module-scoped. The discussion pretty much started off as being lexically/file scoped. Either way, ~4 years on and with refinements now in the wild for some time, it's definitely something worth raising again in my opinion.
----------------------------------------
Feature #13805: Make refinement scoping to be like that of constants
https://bugs.ruby-lang.org/issues/13805#change-66166
* Author: wardrop (Tom Wardrop)
* Status: Open
* Priority: Normal
* Assignee:
* Target version:
----------------------------------------
Refinements are currently lexically scoped, which makes their use burdensome when one wants to apply a refinement to an entire project, requiring boiler plate at the top of every project file. I propose that there ought to be a method of applying refinements to an entire namespace (module), similar to how constants are scoped.
For example, here's a trivial example of how one is able to scope a new RuntimeError class inside a module.
~~~ ruby
# a.rb
require 'b'
module MyProject
class RuntimeError < ::RuntimeError; end
end
# b.rb
module MyProject
class SomeClass
def initialize
raise RuntimeError, "Application error occurred" # Raises MyProject::RuntimeError exception
end
end
~~~
Could refinements be scoped in a similar way, without the requirement for the `using` clause in every file. For example:
~~~ ruby
# a.rb
require 'b'
module MyProject
refine! String do
def exclaim
self + "!!!"
end
end
end
# b.rb
module MyProject
class SomeClass
def initialize
puts "Hello".exclaim # Outputs "Hello!!!"
end
end
~~~
I believe this would be an intuitive means of making refinements global to a project, which seems to be a highly desired feature, and something that needs to happen to mostly eliminate monkey patching. Of course, using the `refine` name would clash with the current behaviour of refine and break backwards compatibility, so I'd propose introducing `refine!` as an alternative to invoke this proposed new behaviour.
Apologies if this has already been proposed/discussed. I did search for similar proposals, but couldn't find anything. I'm interested to hear what some of the potential pitfalls of this would be.
--
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>