[#79440] [Ruby trunk Bug#13188] Reinitialize Ruby VM. — shyouhei@...
Issue #13188 has been updated by Shyouhei Urabe.
6 messages
2017/02/06
[#79441] Re: [Ruby trunk Bug#13188] Reinitialize Ruby VM.
— SASADA Koichi <ko1@...>
2017/02/06
On 2017/02/06 10:10, shyouhei@ruby-lang.org wrote:
[#79532] Immutable Strings vs Symbols — Daniel Ferreira <subtileos@...>
Hi,
15 messages
2017/02/15
[#79541] Re: Immutable Strings vs Symbols
— Rodrigo Rosenfeld Rosas <rr.rosas@...>
2017/02/15
Em 15-02-2017 05:05, Daniel Ferreira escreveu:
[#79543] Re: Immutable Strings vs Symbols
— Daniel Ferreira <subtileos@...>
2017/02/16
Hi Rodrigo,
[#79560] Re: Immutable Strings vs Symbols
— Rodrigo Rosenfeld Rosas <rr.rosas@...>
2017/02/16
Em 15-02-2017 22:39, Daniel Ferreira escreveu:
[ruby-core:79661] [Ruby trunk Feature#9846][Rejected] Regexp#to_regexp
From:
matz@...
Date:
2017-02-22 07:06:03 UTC
List:
ruby-core #79661
Issue #9846 has been updated by Yukihiro Matsumoto. Status changed from Open to Rejected Is there any concrete use-case? Consistency is not the best reason. This proposal leads against Duck typing. Matz. ---------------------------------------- Feature #9846: Regexp#to_regexp https://bugs.ruby-lang.org/issues/9846#change-63078 * Author: Wayne Conrad * Status: Rejected * Priority: Normal * Assignee: * Target version: ---------------------------------------- There should be `Regexp#to_regexp`, just as there is `Array#to_ary` and `String#to_str`. ```ruby p [].to_ary # => [] p ''.to_str # => "" p //.to_regexp # undefined method `to_regexp`... ``` The use case is code like this: ```ruby if o.respond_to?(:to_ary) # do something with o.to_ary elsif o.respond_to?(:to_str) # do something with o.to_str elsif o.respond_to?(to_regexp) # can't do this today # do something with o.to_regexp ``` The workaround is to use `Regexp.try_convert`. `Regexp.try_convert` accepts either a `Regexp` or an object that responds to `#to_regexp`; so this code works fine (and is in some ways better): ```ruby elsif re = Regexp.try_convert(o) # do something with o ``` Still, that `Regexp` does not respond to `#to_regexp` surprised me. Does it surprise anyone else? ---Files-------------------------------- 0001-re.c-rb_reg_to_regexp-add-to_regexp.patch (2 KB) -- 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>