ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
From: shyouhei@ruby-lang.org
To: ruby-core@ruby-lang.org
Subject: [ruby-core:82991] [Ruby trunk Feature#12533] Refinements: allow modules inclusion, in which the module can call internal methods which it defines.
Date: Mon, 25 Sep 2017 12:28:14 +0000 (UTC)	[thread overview]
Message-ID: <redmine.journal-66899.20170925122813.f1287b5c442ef08a@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-12533.20160629121143@ruby-lang.org

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 <main>': 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/

  parent reply	other threads:[~2017-09-25 12:28 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <redmine.issue-12533.20160629121143@ruby-lang.org>
2016-06-29 12:11 ` [ruby-core:76197] [Ruby trunk Feature#12533] Refinements: allow modules inclusion, in which the module can call internal methods which it defines cardoso_tiago
2016-06-29 12:12 ` [ruby-core:76198] " cardoso_tiago
2016-06-29 13:32 ` [ruby-core:76205] " futu.fata
2016-06-29 13:34 ` [ruby-core:76206] " futu.fata
2016-07-08  7:22 ` [ruby-core:76315] [Ruby trunk Feature#12533][Assigned] " shugo
2017-06-13  0:27 ` [ruby-core:81655] [Ruby trunk Feature#12533] " shevegen
2017-09-25  7:05 ` [ruby-core:82968] " duerst
2017-09-25 12:28 ` shyouhei [this message]
2017-09-26  8:34 ` [ruby-core:83019] " matz
2017-10-06 11:59 ` [ruby-core:83159] " cardoso_tiago

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-66899.20170925122813.f1287b5c442ef08a@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).