From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS4713 221.184.0.0/13 X-Spam-Status: No, score=-3.0 required=3.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,SPF_PASS,T_DKIM_INVALID shortcircuit=no autolearn=ham autolearn_force=no version=3.4.0 Received: from neon.ruby-lang.org (neon.ruby-lang.org [221.186.184.75]) by dcvr.yhbt.net (Postfix) with ESMTP id 7B4D5202A5 for ; Mon, 25 Sep 2017 12:28:22 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id 1583D1209E0; Mon, 25 Sep 2017 21:28:19 +0900 (JST) Received: from o1678948x4.outbound-mail.sendgrid.net (o1678948x4.outbound-mail.sendgrid.net [167.89.48.4]) by neon.ruby-lang.org (Postfix) with ESMTPS id EBD2B1209DC for ; Mon, 25 Sep 2017 21:28:16 +0900 (JST) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=sendgrid.me; h=from:to:references:subject:mime-version:content-type:content-transfer-encoding:list-id; s=smtpapi; bh=J8IMb714b6G+kwCLxHCxdS0Nob4=; b=OGP/7NHrsfNQOEKGfF LCKbX57HAB0z3Y6mIPLQSXkX7EQht3jDG1LIOc5/jhyHpS/PsWyABPzBe6mhZqQb WVciaLqRJ8Ta9niOHJYN5/6NozV6hiNSxn/CrePTSPEOKm2TvAaX5vlLIvn1Q3iW woOk3Ozo0w9VV/7+BPGnAmuoY= Received: by filter0016p3mdw1.sendgrid.net with SMTP id filter0016p3mdw1-9876-59C8F65D-19 2017-09-25 12:28:13.28231244 +0000 UTC Received: from herokuapp.com (ec2-54-160-132-132.compute-1.amazonaws.com [54.160.132.132]) by ismtpd0005p1iad2.sendgrid.net (SG) with ESMTP id j3QbplicRUuFNEQH9jEMWA Mon, 25 Sep 2017 12:28:13.224 +0000 (UTC) Date: Mon, 25 Sep 2017 12:28:14 +0000 (UTC) From: shyouhei@ruby-lang.org To: ruby-core@ruby-lang.org Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 58092 X-Redmine-Project: ruby-trunk X-Redmine-Issue-Id: 12533 X-Redmine-Issue-Author: chucke X-Redmine-Issue-Assignee: matz X-Redmine-Sender: shyouhei X-Mailer: Redmine X-Redmine-Host: bugs.ruby-lang.org X-Redmine-Site: Ruby Issue Tracking System X-Auto-Response-Suppress: All Auto-Submitted: auto-generated X-SG-EID: ync6xU2WACa70kv/Ymy4QrNMhiuLXJG8OTL2vJD1yS7Sy4ZuPi4+vUiHzLQ38P+gAs+F56BWzDnlJH 7w6ECn2eA4Akq0slsfMDYl3DpmmsuBNpOePvp1gAVARzMf4BzxiaxJnKWv1weM+9vkw5xuYELgfXXZ GcWkRdfJJMcAYc09HuRfAbEdvkgXAMl4O5cfC6ZUXyccJ91bN1XK/0E+Nw== X-ML-Name: ruby-core X-Mail-Count: 82991 Subject: [ruby-core:82991] [Ruby trunk Feature#12533] Refinements: allow modules inclusion, in which the module can call internal methods which it defines. X-BeenThere: ruby-core@ruby-lang.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: Ruby developers List-Id: Ruby developers List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ruby-core-bounces@ruby-lang.org Sender: "ruby-core" Issue #12533 has been updated by shyouhei (Shyouhei Urabe). We looked at this issue at a developer meeting today. The OP's intension is clear. We can describe how it works, but that seems to be different from how it _should_ work. Matz was there at the discussion so he understands the situation. I'm sure he's going to have some decision. ---------------------------------------- Feature #12533: Refinements: allow modules inclusion, in which the module can call internal methods which it defines. https://bugs.ruby-lang.org/issues/12533#change-66899 * Author: chucke (Tiago Cardoso) * Status: Assigned * Priority: Normal * Assignee: matz (Yukihiro Matsumoto) * Target version: ---------------------------------------- Right now this isn't possible: ~~~ruby module Extensions def vegetables ; potatoe ; end def potatoe ; "potatoe" ; end end module Refinary refine String do # this doesn't work include Extensions # this would work... # def vegetables ; potatoe ; end # def potatoe ; "potatoe" ; end end end using Refinary puts "tomatoe".vegetables #=> in
': undefined method 'vegetables' for "tomatoe":String ~~~ Wrongly reported as a bug [here](https://bugs.ruby-lang.org/issues/12514). According to Shugo Maeda, this was expected behaviour. I argued that this is the way most monkey-patches work, and if Refinements can't cover the use case of inserting a custom DSL which references itself in the classes it refines, it can't fully replace monkey-patches, which I read was the main reason Refinements have been added to the language. -- https://bugs.ruby-lang.org/