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_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_MED,SPF_PASS,T_DKIM_INVALID, T_RP_MATCHES_RCVD 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 C3B5820401 for ; Tue, 13 Jun 2017 00:27:59 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id E69941207BA; Tue, 13 Jun 2017 09:27:57 +0900 (JST) Received: from o1678916x28.outbound-mail.sendgrid.net (o1678916x28.outbound-mail.sendgrid.net [167.89.16.28]) by neon.ruby-lang.org (Postfix) with ESMTPS id 2B7531207A3 for ; Tue, 13 Jun 2017 09:27:54 +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=4ZARpt49cvxtDqhEqZQMVN+mfyg=; b=Q1YunEdCSGxAzbMg19 JF/YEdvRHR+LEN6lNtL1G0GEJTKGRXeCAtLTC8qKIrQpDQEmISRUul3uuiPLZ1t9 XmOskG3G8JkUzXvFeXACzcicRIu1O0qvymMgOmFPhF2wYd7RFX8D1e+fgMvnRaFb /+k4tb68oRwKcS0zJIIV3+aVE= Received: by filter1113p1mdw1.sendgrid.net with SMTP id filter1113p1mdw1-25856-593F3187-2A 2017-06-13 00:27:51.695005828 +0000 UTC Received: from herokuapp.com (ec2-54-221-13-70.compute-1.amazonaws.com [54.221.13.70]) by ismtpd0002p1iad1.sendgrid.net (SG) with ESMTP id iqyLkxl-S4Wn-jDnWaHOJQ Tue, 13 Jun 2017 00:27:51.623 +0000 (UTC) Date: Tue, 13 Jun 2017 00:27:51 +0000 From: shevegen@gmail.com To: ruby-core@ruby-lang.org Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 56684 X-Redmine-Project: ruby-trunk X-Redmine-Issue-Id: 12533 X-Redmine-Issue-Author: chucke X-Redmine-Issue-Assignee: matz X-Redmine-Sender: shevegen 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/Ymy4QrNMhiuLXJG8OTL2vJD1yS5/hgUXr/EpfjAymVotyad5xLoasCVGo0yMfT 87Ezdd1pc3wyaAN2VFZ7HL+FqyNNpi8ZEb/WGNSWc/9dOht5qsBYPHZ6oDEFZ2XfRYtEZDCM61nYLE EjORc04WbXerVhSgz0ZYuQhx+OjaNtJzAPMsLaZZBxPOnkMuGr5lyqDYBQ== X-ML-Name: ruby-core X-Mail-Count: 81655 Subject: [ruby-core:81655] [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 shevegen (Robert A. Heiler). Sorry for slight off-topic from me here - I wonder if refinements will be refined when ruby 3.x comes out ... :) ---------------------------------------- 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-65352 * 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/