ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
From: shugo@ruby-lang.org
To: ruby-core@ruby-lang.org
Subject: [ruby-core:104651] [Ruby master Bug#17429] Prohibit include/prepend in refinement modules
Date: Tue, 20 Jul 2021 07:53:37 +0000 (UTC)	[thread overview]
Message-ID: <redmine.journal-92960.20210720075336.12@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-17429.20201223022216.12@ruby-lang.org

Issue #17429 has been updated by shugo (Shugo Maeda).


Eregon (Benoit Daloze) wrote in #note-20:
> One more issue reported due these confusing semantics of include/prepend inside `refine`: #18021.
> 
> I suggest we warn in 3.1, raise in 3.2.
> And I suggest to add `Refinement#import`, because:
> * `mix` seems to imply other things, and if it's ever added to Module with different semantics we will just get more confusion.
> * `include` seems likely to cause confusion because the behavior would not be Module#include-like. It is also potentially backward-incompatible, raises the question about what would happen for `prepend` and consistency. And finnaly `include` would not longer mean "define higher in the ancestor" for this context, i.e., defining the same method in the refine block would replace, not just override).

I've implemented Refinement#import in https://github.com/shugo/ruby/pull/3

In the current implementation, the module in cref is replaced with the refinement like Module#dup, so constants in the imported module are not accessible from the copied methods.
It would be possible to support constant access with a hack on cref, but I'm afraid it may bring new problems.

Maybe Refinement#import_methods is a better name if we keep the current behavior.


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

* Author: shugo (Shugo Maeda)
* Status: Open
* Priority: Normal
* Assignee: matz (Yukihiro Matsumoto)
* 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/

  parent reply	other threads:[~2021-07-20  7:53 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-23  2:22 [ruby-core:101639] [Ruby master Bug#17429] Prohibit include/prepend in refinement modules shugo
2020-12-23  5:44 ` [ruby-core:101642] " matz
2020-12-23 11:00 ` [ruby-core:101646] " eregontp
2020-12-23 17:04 ` [ruby-core:101663] " marcandre-ruby-core
2020-12-23 19:19 ` [ruby-core:101664] " daniel
2021-01-06  1:49 ` [ruby-core:101943] " merch-redmine
2021-01-13  8:08 ` [ruby-core:102058] " ronnie
2021-01-13 11:49 ` [ruby-core:102059] " eregontp
2021-01-14  3:15 ` [ruby-core:102081] " shugo
2021-01-14 13:34 ` [ruby-core:102093] " daniel
2021-01-20  7:43 ` [ruby-core:102179] " shugo
2021-01-20 10:45 ` [ruby-core:102181] " eregontp
2021-01-22 18:30 ` [ruby-core:102198] " marcandre-ruby-core
2021-01-26  1:47 ` [ruby-core:102247] " shugo
2021-01-29  9:34 ` [ruby-core:102296] " ko1
2021-01-29 12:21 ` [ruby-core:102298] " eregontp
2021-07-04 10:26 ` [ruby-core:104502] " eregontp
2021-07-04 10:35 ` [ruby-core:104503] " eregontp
2021-07-20  7:53 ` shugo [this message]
2021-07-23 10:02 ` [ruby-core:104664] " eregontp
2021-07-26  0:02 ` [ruby-core:104676] " shugo
2021-07-26 11:12 ` [ruby-core:104680] " eregontp
2021-07-26 11:15 ` [ruby-core:104681] " eregontp
2021-07-27  2:37 ` [ruby-core:104690] " shugo
2021-09-10  7:42 ` [ruby-core:105189] " shugo (Shugo Maeda)
2021-09-16 14:09 ` [ruby-core:105302] " mame (Yusuke Endoh)
2021-09-16 14:11 ` [ruby-core:105303] " mame (Yusuke Endoh)
2021-09-17  2:57 ` [ruby-core:105318] " shugo (Shugo Maeda)
2021-09-17  9:48 ` [ruby-core:105326] " shugo (Shugo Maeda)
2021-09-28 23:21 ` [ruby-core:105475] " shugo (Shugo Maeda)
2021-10-21  5:42 ` [ruby-core:105712] " matz (Yukihiro Matsumoto)
2021-10-21  5:43 ` [ruby-core:105713] " shugo (Shugo Maeda)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.ruby-lang.org/en/community/mailing-lists/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=redmine.journal-92960.20210720075336.12@ruby-lang.org \
    --to=ruby-core@ruby-lang.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).