Issue #12790 has been updated by Robert A. Heiler.


That the object id is displayed also used to confuse me. I adjusted to it
so it is fine but I don't think I ever really needed to know the object
id. Perhaps it visually looks cuter if the object id is shown. :)

On a slightly related note, I think that Aaron Petterson wrote the "I
am a puts debugger" blog entry.

    https://tenderlovemaking.com/2016/02/05/i-am-a-puts-debuggerer.html

I am also a puts debugger, or actually, I am a pp debugger. I usually
end up doing

    require 'pp'

Would be nice if pp would be available all the time without a require
statement. But anyway, sorry for commenting this here on an unrelated
entry, I just wanted to mention it because debug-inspect output was
the topic.

Back to date and time - I actually never noticed this, this is 
interesting. But to be honest, I don't think I really needed that
information. I think I have had customized inspect output for my own
code only two or three times in 10 years or so. The only use case I
really once had was for a MUD engine started in ruby, where I needed
the objects (like a sword) to show some more meaningful output in
general. Other than that, I don't think I actually paid that much
attention to the inspect output - providing a to_str (or was it 
to_s, I always mix them up) method was then usually more important.

----------------------------------------
Feature #12790: Better inspect for stdlib classes
https://bugs.ruby-lang.org/issues/12790#change-60724

* Author: Victor Shepelev
* Status: Open
* Priority: Normal
* Assignee: 
----------------------------------------
`#inspect` is important for understanding "what I have" in irb/pry, and in [puts-debugging](https://tenderlovemaking.com/2016/02/05/i-am-a-puts-debuggerer.html), and in ton of other cases.

Sadly, some of important stdlib classes (in my opinion) fail to provide concise and readable representation for `#inspect`.

Some examples below:

## `BigDecimal` (important for representing money values, for example)

Current behavior:

```ruby
#<BigDecimal:128d34f4,'0.25E2',9(18)>
#   ^           ^        ^      ^
#   1           2        3      4
```
1. OK, this is reasonable
2. Do we really need object id here? As far as I can understand, developer is typically concerned only about numeric value identity, not object identity for bigdecimals.
3. OK, I understand about scientific representation, but it is hard to read (at least for me), and also single quotes around add to a confusion.
4. I'm not sure. Number of significant digits it is. So, what are the situation when you need to look at it constantly?..

So, ideal behavior:

```ruby
#<BigDecimal: 250>
# or, preserving num. of sig.dig.
#<BigDecimal: 250 digits: 9(18)>
# ...or something like this

# But for really large numbers it is still
#<BigDecimal: 1.5E35>
```

Side note: try to guess what `BigDecimal.new(2)**10_000` looks like?.. And whether this look is really useful for anything.

## `Date` and `DateTime`

```ruby
Date.today
# => #<Date: 2016-09-26 ((2457658j,0s,0n),+0s,2299161j)>
DateTime.now
# => #<DateTime: 2016-09-26T16:40:17+03:00 ((2457658j,49217s,186886101n),+10800s,2299161j)>
```

Maybe it is just me, but it does not look like part in parenthises (and double parenthises!) contain information of such real importance that it can change our perception of "what's going on"?.. If you work with current dates, it is just unnecessary; if you work with some really complicated historical dates, it is not enough, being too concise and enigmatic to give some understanding of epochs and calendars.

(And to add, it is awfully inconsistent with Time's `#inspect`, which does provide just `2016-09-26 17:03:59 +0300`.)




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