[#73707] [Ruby trunk Misc#12004] Code of Conduct — hanmac@...
Issue #12004 has been updated by Hans Mackowiak.
3 messages
2016/02/05
[#73730] [Ruby trunk Feature#12034] RegExp does not respect file encoding directive — nobu@...
Issue #12034 has been updated by Nobuyoshi Nakada.
3 messages
2016/02/07
[#73746] [Ruby trunk Feature#12034] RegExp does not respect file encoding directive — nobu@...
Issue #12034 has been updated by Nobuyoshi Nakada.
3 messages
2016/02/09
[#73919] [Ruby trunk Feature#11262] Make more objects behave like "Functions" — Ruby-Lang@...
Issue #11262 has been updated by J旦rg W Mittag.
3 messages
2016/02/22
[#74019] [Ruby trunk Bug#12103][Rejected] ruby process hangs while executing regular expression. — duerst@...
Issue #12103 has been updated by Martin D端rst.
3 messages
2016/02/27
[ruby-core:73904] [Ruby trunk Feature#12079] Loosening the condition for refinement
From:
sawadatsuyoshi@...
Date:
2016-02-21 02:14:03 UTC
List:
ruby-core #73904
Issue #12079 has been updated by Tsuyoshi Sawada.
There is a point that needs to be made clear regarding this proposal: whether the symbol or string used in the construction has to be a literal. I think there would be use cases where the symbol/string is expressed as more complex expression:
~~~RUBY
module Foo
refine String do
def baz; end
end
end
def a
case some_expression
when "x" then :baz
when "y" then :bar
end
end
using Foo
["a", "b", "c"].map(&(some_condition ? :baz : :bar))
"a".__send__("BAZ".downcase)
"a".send(a)
~~~
In order for the proposal to be useful, I think the relevant symbol/string should not be restricted to literals. Furthermore, the location where the expression is expanded to a symbol/string should not matter; solely the location of `&` or `send`, etc. should matter. In above, while `send` is within the scope of refinement, `a`, which can be possibly expanded to `:baz`, is expanded outside of the scope of refinement. In such cases too, I think the refinement should be effective.
----------------------------------------
Feature #12079: Loosening the condition for refinement
https://bugs.ruby-lang.org/issues/12079#change-57064
* Author: Tsuyoshi Sawada
* Status: Open
* Priority: Normal
* Assignee:
----------------------------------------
There are a few non-standard ways of calling a method that cannot be used when the relevant method is a refined method:
* a symbol used with `&` as a block via symbol to proc
* a symbol used with `send` or `__send__`
For example, the following will fail:
~~~RUBY
module Foo
refine String
def baz; end
end
end
using Foo
["a", "b", "c"].map(&:baz) # => undefined method error
"a".send(:baz) # => undefined method error
~~~
I would like to propose to loosen the condition for refinement so that as long as the relevant construction (such as the use of `&` to provoke `Symbol#to_proc` or calling of `send` or `__send__`) is within the valid scope of refinement, allow the call to the relevant methods.
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>