[#92070] [Ruby trunk Feature#15667] Introduce malloc_trim(0) in full gc cycles — sam.saffron@...
Issue #15667 has been updated by sam.saffron (Sam Saffron).
3 messages
2019/04/01
[ruby-core:92470] [Ruby trunk Bug#15745] There is no symmetry in the beginless range and the endless range using `Range#inspect`
From:
mame@...
Date:
2019-04-29 00:05:19 UTC
List:
ruby-core #92470
Issue #15745 has been updated by mame (Yusuke Endoh).
Eregon (Benoit Daloze) wrote:
> I'm not sure what you mean by DSL-like usage, but I wouldn't be surprised if many people use it like `array[..-2]` (instead of `array[0..-2]`).
> In other words, I'd expect it's approximately as common as endless ranges for the purpose of indexing a sequence.
I meant "DSL-like", for example, `debtors = Accounts.where(balance: ...0)`.
I strongly prefer `ary[0..]` to `ary[0..-1]` because the former has no magical -1. However, IMHO, there is no strong reason to prefer `ary[..-2]` to `ary[0..-2]` because 0 is not so magical in terms of indexing. It would be useful where non-zero-based indexing is used, but I don't think that it is common in Ruby.
In addition, an endless range has another big usage: `(1..).each { ... }`. On the other hand, a beginless range cannot iterate.
So, I believe that a beginless range has much less usages, and this is one of the reasons why a beginless range was not introduced with an endless one. That being said, I'm unsure if `Range#inspect` is mainly used for endless range.
----------------------------------------
Bug #15745: There is no symmetry in the beginless range and the endless range using `Range#inspect`
https://bugs.ruby-lang.org/issues/15745#change-77818
* Author: koic (Koichi ITO)
* Status: Open
* Priority: Normal
* Assignee:
* Target version:
* ruby -v: ruby 2.7.0dev (2019-04-03 trunk 67423) [x86_64-darwin17]
* Backport: 2.4: UNKNOWN, 2.5: UNKNOWN, 2.6: UNKNOWN
----------------------------------------
The following commit introduces beginless range.
https://github.com/ruby/ruby/commit/95f7992b89efd35de6b28ac095c4d3477019c583
```
% ruby -v
ruby 2.7.0dev (2019-04-03 trunk 67423) [x86_64-darwin17]
```
There is no symmetry with endless range when using `Range#inspect` method.
```
(1..).inspect # => "1.."
(..5).inspect # => "nil..5"
```
How about unifying whether it represents `nil`?
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:[email protected]?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>