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=-1.9 required=3.0 tests=BAYES_00,DKIM_SIGNED, FORGED_HOTMAIL_RCVD2,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,SPF_PASS, T_DKIM_INVALID shortcircuit=no autolearn=no 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 2694B2036B for ; Fri, 6 Oct 2017 11:59:22 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id 0714A12094E; Fri, 6 Oct 2017 20:59:19 +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 58BAB120949 for ; Fri, 6 Oct 2017 20:59:17 +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=fnToHEq7O1BizrB3ZLkVAmHuzpY=; b=BOP9+K+PewZbfowQa3 ZLgbeRVNU5mW/4H5b4CZoNmLbBlaHU/Uz6OtMuwfRwmb6h9+X3WZCbRFu424ClLo ivOxu/uRY7hAHZybC90mQmxN3L+kKxzPantsY9rYyCSIYdo21vvju2bjdO65aXbR yMB4B0QkfwjwVXUZZGWigZObQ= Received: by filter0010p3mdw1.sendgrid.net with SMTP id filter0010p3mdw1-20648-59D77011-6 2017-10-06 11:59:13.363852632 +0000 UTC Received: from herokuapp.com (ec2-54-163-152-129.compute-1.amazonaws.com [54.163.152.129]) by ismtpd0004p1iad1.sendgrid.net (SG) with ESMTP id 47z94AsTTfKHa4NfhvpKPw Fri, 06 Oct 2017 11:59:13.229 +0000 (UTC) Date: Fri, 06 Oct 2017 11:59:14 +0000 (UTC) From: cardoso_tiago@hotmail.com To: ruby-core@ruby-lang.org Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 58251 X-Redmine-Project: ruby-trunk X-Redmine-Issue-Id: 12533 X-Redmine-Issue-Author: chucke X-Redmine-Issue-Assignee: matz X-Redmine-Sender: chucke 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/Ymy4QrNMhiuLXJG8OTL2vJD1yS5ZjV7Jm+dvdGu+5GViEDgYoNoQm+P7QK4VvZ cVOzVpI46wMmXs9V7hRTSkyo7ShQGUktUGC0txRzX50Vl/JWzhFkNisdNhZfHLMcHOdaNy0bmq5bVd M3EuHbrF3+Xdp/SlQhhSy1OPWfGTmMjwDTEDnlF1Pao4LItENGn/dFudUg== X-ML-Name: ruby-core X-Mail-Count: 83159 Subject: [ruby-core:83159] [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 chucke (Tiago Cardoso). How about redefining `#include` in the context of refine as what would be expected of the new `#inject` method? I get that the semantics of module inclusion differ in both context regarding inheritance hierarchy order, but I'm still thinking from the user perspective: "if I do it, what do I expect to happen?". >From this user perspective, I'd prefer an `#include` method which does what I expect, instead of yet another method (`#inject`) that I have to learn. But there might be other implications. I'm fine with whichever proposal which makes refinements more usable for meta-programming. ---------------------------------------- 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-67095 * 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/