ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-core:76199] [Ruby trunk Feature#12534] Refinements: refine modules as well
       [not found] <redmine.issue-12534.20160629121958@ruby-lang.org>
@ 2016-06-29 12:19 ` cardoso_tiago
  2016-06-30  3:51 ` [ruby-core:76208] " shevegen
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 4+ messages in thread
From: cardoso_tiago @ 2016-06-29 12:19 UTC (permalink / raw
  To: ruby-core

Issue #12534 has been reported by Tiago Cardoso.

----------------------------------------
Feature #12534: Refinements: refine modules as well
https://bugs.ruby-lang.org/issues/12534

* Author: Tiago Cardoso
* Status: Open
* Priority: Normal
* Assignee: 
----------------------------------------
Refinements were added as a feature to scope monkey-patches on ruby core elements. This works for elements such as String, Array (all classes), but not for modules (Enumerable, Timeout...). 

This might be related to refinements not working for singleton classes (for example, I can't define a class method inside a refine block). 

This code is evaluated, but the method is undefined:

module Extension
 refine Array do
   def self.foo ; puts "bar" ; end
 end
end

This code breaks:

module Extension
 refine Kernel do
   def foo ; puts "bar" ; end
 end
end





-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [ruby-core:76208] [Ruby trunk Feature#12534] Refinements: refine modules as well
       [not found] <redmine.issue-12534.20160629121958@ruby-lang.org>
  2016-06-29 12:19 ` [ruby-core:76199] [Ruby trunk Feature#12534] Refinements: refine modules as well cardoso_tiago
@ 2016-06-30  3:51 ` shevegen
  2016-07-08  7:18 ` [ruby-core:76314] [Ruby trunk Feature#12534][Feedback] " shugo
  2016-09-07  8:03 ` [ruby-core:77195] [Ruby trunk Feature#12534] " matz
  3 siblings, 0 replies; 4+ messages in thread
From: shevegen @ 2016-06-30  3:51 UTC (permalink / raw
  To: ruby-core

Issue #12534 has been updated by Robert A. Heiler.


Interesting. I was not aware of this.

It is however mentioned in the documentation:

  http://ruby-doc.org/core-2.3.1/doc/syntax/refinements_rdoc.html

Quote:

"Refinements only modify classes, not modules so the argument must be a class."

As to why, I don't know either. Perhaps the documentation can add some words
to briefly state whether this is on purpose or not.

----------------------------------------
Feature #12534: Refinements: refine modules as well
https://bugs.ruby-lang.org/issues/12534#change-59424

* Author: Tiago Cardoso
* Status: Open
* Priority: Normal
* Assignee: 
----------------------------------------
Refinements were added as a feature to scope monkey-patches on ruby core elements. This works for elements such as String, Array (all classes), but not for modules (Enumerable, Timeout...). 

This might be related to refinements not working for singleton classes (for example, I can't define a class method inside a refine block). 

This code is evaluated, but the method is undefined:

module Extension
 refine Array do
   def self.foo ; puts "bar" ; end
 end
end

This code breaks:

module Extension
 refine Kernel do
   def foo ; puts "bar" ; end
 end
end





-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [ruby-core:76314] [Ruby trunk Feature#12534][Feedback] Refinements: refine modules as well
       [not found] <redmine.issue-12534.20160629121958@ruby-lang.org>
  2016-06-29 12:19 ` [ruby-core:76199] [Ruby trunk Feature#12534] Refinements: refine modules as well cardoso_tiago
  2016-06-30  3:51 ` [ruby-core:76208] " shevegen
@ 2016-07-08  7:18 ` shugo
  2016-09-07  8:03 ` [ruby-core:77195] [Ruby trunk Feature#12534] " matz
  3 siblings, 0 replies; 4+ messages in thread
From: shugo @ 2016-07-08  7:18 UTC (permalink / raw
  To: ruby-core

Issue #12534 has been updated by Shugo Maeda.

Status changed from Open to Feedback
Assignee set to Shugo Maeda

There is an implementation difficulty when refining modules and calling `super` in that refinement.

One solution is prohibiting `super` in a refinement for a module.
Other proposals (and patches) are welcome.


----------------------------------------
Feature #12534: Refinements: refine modules as well
https://bugs.ruby-lang.org/issues/12534#change-59550

* Author: Tiago Cardoso
* Status: Feedback
* Priority: Normal
* Assignee: Shugo Maeda
----------------------------------------
Refinements were added as a feature to scope monkey-patches on ruby core elements. This works for elements such as String, Array (all classes), but not for modules (Enumerable, Timeout...). 

This might be related to refinements not working for singleton classes (for example, I can't define a class method inside a refine block). 

This code is evaluated, but the method is undefined:

module Extension
 refine Array do
   def self.foo ; puts "bar" ; end
 end
end

This code breaks:

module Extension
 refine Kernel do
   def foo ; puts "bar" ; end
 end
end





-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [ruby-core:77195] [Ruby trunk Feature#12534] Refinements: refine modules as well
       [not found] <redmine.issue-12534.20160629121958@ruby-lang.org>
                   ` (2 preceding siblings ...)
  2016-07-08  7:18 ` [ruby-core:76314] [Ruby trunk Feature#12534][Feedback] " shugo
@ 2016-09-07  8:03 ` matz
  3 siblings, 0 replies; 4+ messages in thread
From: matz @ 2016-09-07  8:03 UTC (permalink / raw
  To: ruby-core

Issue #12534 has been updated by Yukihiro Matsumoto.


I understand the implementation difficulty. If we prohibit `super` in refined methods in Modules, is it possible to refine modules?
If it's reasonably possible, I'd like to accept this.

Matz.


----------------------------------------
Feature #12534: Refinements: refine modules as well
https://bugs.ruby-lang.org/issues/12534#change-60410

* Author: Tiago Cardoso
* Status: Feedback
* Priority: Normal
* Assignee: Shugo Maeda
----------------------------------------
Refinements were added as a feature to scope monkey-patches on ruby core elements. This works for elements such as String, Array (all classes), but not for modules (Enumerable, Timeout...). 

This might be related to refinements not working for singleton classes (for example, I can't define a class method inside a refine block). 

This code is evaluated, but the method is undefined:

module Extension
 refine Array do
   def self.foo ; puts "bar" ; end
 end
end

This code breaks:

module Extension
 refine Kernel do
   def foo ; puts "bar" ; end
 end
end





-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-09-07  7:31 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <redmine.issue-12534.20160629121958@ruby-lang.org>
2016-06-29 12:19 ` [ruby-core:76199] [Ruby trunk Feature#12534] Refinements: refine modules as well cardoso_tiago
2016-06-30  3:51 ` [ruby-core:76208] " shevegen
2016-07-08  7:18 ` [ruby-core:76314] [Ruby trunk Feature#12534][Feedback] " shugo
2016-09-07  8:03 ` [ruby-core:77195] [Ruby trunk Feature#12534] " matz

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).