Issue #17429 has been updated by Dan0042 (Daniel DeLorme).


I agree the current situation needs to be fixed, and prohibiting include/prepend is the simplest way. But I also think there has to be a way to achieve what Marc-Andre was trying in #17374.

marcandre (Marc-Andre Lafortune) wrote in #note-3:
> ```ruby
> refine Object, import: Code do
>   # extra methods
> end
> ```

That looks pretty good I think.

> I still think that `include` and `prepend` within the `refine` block could have that function.

But there's not much benefit to that is there? Having a different name such as `import` feels cleaner. Using `include` or `prepend` within a refine block could result in a warning/error along the lines of "`include` is not supported in refinements but you can use the almost-equivalent `import` argument."

----------------------------------------
Bug #17429: Prohibit include/prepend in refinement modules
https://bugs.ruby-lang.org/issues/17429#change-89483

* Author: shugo (Shugo Maeda)
* Status: Open
* Priority: Normal
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN
----------------------------------------
include/prepend in refinement modules has implementation difficulties such as #17007 and #17379, and tends to be misleading like #17374.
How about to prohibit it in future versions?

Method copy like #17380 may be more convenient, but it's confusing to use names include and prepend because semantics is different from the original ones.




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