[#86787] [Ruby trunk Feature#14723] [WIP] sleepy GC — ko1@...

Issue #14723 has been updated by ko1 (Koichi Sasada).

13 messages 2018/05/01
[#86790] Re: [Ruby trunk Feature#14723] [WIP] sleepy GC — Eric Wong <normalperson@...> 2018/05/01

ko1@atdot.net wrote:

[#87095] [Ruby trunk Feature#14767] [PATCH] gc.c: use monotonic counters for objspace_malloc_increase — ko1@...

Issue #14767 has been updated by ko1 (Koichi Sasada).

9 messages 2018/05/17

[ruby-core:87011] [Ruby trunk Feature#14249] Remove str[match_str]

From: yugui@...
Date: 2018-05-13 23:32:58 UTC
List: ruby-core #87011
Issue #14249 has been updated by yugui (Yuki Sonoda).


IIUC, Ana is saying that `str[match_str]` does not make sense because it always returns `match_str`.
But it does make sense because it returns `nil` if `str` does not contain such a substring. i.e. it is useful to test if the string contains a substring.

You would say that `str[regex]` can do the same thing. And theoretically it is true. But it also means you must compile `match_str` into `Regexp` beforehand.
So `str[match_str]` is a convenient (and sometimes more efficient) way to test substrings.

Then, you might say that `str.contains` can do the same thing. And theoretically it is true. Here `str[match_str]` is necessary to just keep compatibility between `String` and `Regexp`.
Since most of all methods in the standard library which expect a pattern of character sequence accepts both of `String` and `Regexp`, it is natural for users to expect that the compatibility is kept in `String#[]` too.

----------------------------------------
Feature #14249: Remove str[match_str]
https://bugs.ruby-lang.org/issues/14249#change-71978

* Author: ana06 (Ana Maria Martinez Gomez)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
----------------------------------------
I wonder if `str[match_str]` makes sense.

``` Ruby
"ana"['a'] => "a"

```

I would say this is not expected and it brings problems, for example when accessing nested hashes. For example:

``` Ruby
params = { "user" => "Nicolas Cage" } => {"user"=>"Nicolas Cage"}

params["user"]["age"] => "age"

```

I think `str[regexp]` is enough and that `str[match_str]` can be removed.



-- 
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>

In This Thread

Prev Next