From: shugo@... Date: 2021-01-20T07:43:02+00:00 Subject: [ruby-core:102179] [Ruby master Bug#17429] Prohibit include/prepend in refinement modules Issue #17429 has been updated by shugo (Shugo Maeda). Dan0042 (Daniel DeLorme) wrote in #note-12: > shugo (Shugo Maeda) wrote in #note-11: > > The behavior is similar to Module#mix proposed by Matz before. > > Visually it's a more pleasing API than the `import` keyword, but would it be available in any module or just refinements? > If any module, we'd now have _three_ mixin mechanisms: include, prepend, import. IMO that's overly complex. > If just refinements, it feels inconsistent. IMO we'll have people asking why they can't use `import` in classes and modules. > As a keyword it's clear this is a refinement-only behavior. It's enough to changing the class of a module created by refine to the following subclass of Module, isn't it? ```ruby class Refinement < Module [:include, :prepend].each do |name| define_method(name) do |*args| warn("#{name} in a refinement is deprecated; use mix instead", uplevel: 1, category: :deprecated) super(*args) end end def mix(*args) # ... end end ``` ---------------------------------------- Bug #17429: Prohibit include/prepend in refinement modules https://bugs.ruby-lang.org/issues/17429#change-90027 * 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: