ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
From: zverok.offline@gmail.com
To: ruby-core@ruby-lang.org
Subject: [ruby-core:92501] [Ruby trunk Bug#15745] There is no symmetry in the beginless range and the endless range using `Range#inspect`
Date: Tue, 30 Apr 2019 16:41:54 +0000 (UTC)	[thread overview]
Message-ID: <redmine.journal-77862.20190430164153.b51c75e6e4e64ee2@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-15745.20190403093730@ruby-lang.org

Issue #15745 has been updated by zverok (Victor Shepelev).


My reasoning is semi-open ranges are valuable feature, and by `inspect` we should suggest to users their "naturalness", not "it is just a quick hack, look". 
Explicit rendering of `nil` is *underlining* some kind of "hackiness" ("it is just a syntactic sugar for `1..nil` underneath"). 
I believe it is an important new language feature, and it should be represented adequately. 
`1..nil`/`nil..1` is not adequate, because it is hard to read: "range from 1 to nothing"? (it doesn't read as "range without end", which it is).

So I'd say that:
1. `p (1..) # => (1..)`, and that's the only adequate representation
2. `p (..1) # => (..1)`, and that's the only adequate representation
3. How `nil..nil` is represented is not THAT important, because it is the rarest and less useful case; I don't think even `(..)` is that bad. It looks kinda weird, but it still is what it is: "range (designated  by `..`) with neither end nor beginning". 

The point is, there could be a discussion about (3), and it is only marginally important; but not about (1) and (2).
In this line of reasoning, "Make `(..1)` looking weird for consistency with `(nil..nil)`" is less than desirable.

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

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

  parent reply	other threads:[~2019-04-30 16:42 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <redmine.issue-15745.20190403093730@ruby-lang.org>
2019-04-03  9:37 ` [ruby-core:92124] [Ruby trunk Bug#15745] There is no symmetry in the beginless range and the endless range using `Range#inspect` koic.ito
2019-04-26  8:04 ` [ruby-core:92417] " mame
2019-04-27 20:50 ` [ruby-core:92448] " eregontp
2019-04-27 22:24 ` [ruby-core:92449] " mame
2019-04-28 11:42 ` [ruby-core:92458] " eregontp
2019-04-28 12:17 ` [ruby-core:92460] " mame
2019-04-28 21:03 ` [ruby-core:92469] " eregontp
2019-04-29  0:05 ` [ruby-core:92470] " mame
2019-04-29 10:34 ` [ruby-core:92474] " zverok.offline
2019-04-30 16:02 ` [ruby-core:92499] " mame
2019-04-30 16:41 ` zverok.offline [this message]
2019-04-30 17:06 ` [ruby-core:92502] " mame
2019-04-30 17:22 ` [ruby-core:92503] " zverok.offline
2019-04-30 21:20 ` [ruby-core:92504] " eregontp
2019-05-22  4:50 ` [ruby-core:92755] " matz

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-77862.20190430164153.b51c75e6e4e64ee2@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).