From: futu.fata@gmail.com
To: ruby-core@ruby-lang.org
Subject: [ruby-core:76206] [Ruby trunk Feature#12533] Refinements: allow modules inclusion, in which the module can call internal methods which it defines.
Date: Wed, 29 Jun 2016 13:34:35 +0000 [thread overview]
Message-ID: <redmine.journal-59422.20160629133435.5ed0c89ad4688b4f@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-12533.20160629121143@ruby-lang.org
Issue #12533 has been updated by Artem Khramov.
Hi Tiago, the syntax is
\~\~\~ruby
your(code).goes here
\~\~\~
Sorry for offtop.
----------------------------------------
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-59422
* Author: Tiago Cardoso
* Status: Open
* Priority: Normal
* Assignee:
----------------------------------------
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/
next prev parent reply other threads:[~2016-06-29 13:00 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 ` futu.fata [this message]
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 ` [ruby-core:82991] " shyouhei
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-59422.20160629133435.5ed0c89ad4688b4f@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).