[ruby-core:78079] [Ruby trunk Feature#12913][Feedback] A way to configure the default maximum width of pp
From:
akr@...
Date:
2016-11-11 02:04:16 UTC
List:
ruby-core #78079
Issue #12913 has been updated by Akira Tanaka.
Status changed from Open to Feedback
Yusuke Endoh wrote:
> In such a case, I think that "break as far as possible" would be useful.
"break as far as possible" is opposite to pp.rb's intent:
"don't break as far as possible (in screen width limitation)".
I think a global configuration to choose different intent for single API is not a good idea.
pp (including pretty_inspect and PP.pp) method is used in many gems.
I think the intent of most of them is "don't break as far as possible".
PP.default_maxwidth = 1 breaks the intent.
I recommend that you define a method to call PP.pp with width = 1.
----------------------------------------
Feature #12913: A way to configure the default maximum width of pp
https://bugs.ruby-lang.org/issues/12913#change-61428
* Author: Yusuke Endoh
* Status: Feedback
* Priority: Normal
* Assignee: Akira Tanaka
----------------------------------------
How about having an easy way to configure the maximum width of a line of `pp` output?
Currently, `pp` accepts the maximum width as an optional argument:
pp(big_array, $>, 120)
However, this is obviously too long for a useful debugging-purpose method like `pp`. Even worse, we must add the fragment "`, $>, 120`" to all calls to `pp`. I don't feel this is reasonable.
The patch attached provides `PP.default_maxwidth=` and `PP.default_maxwidth`, which can be used to configure the default setting of the maxwidth.
PP.default_maxwidth = 1
pp([1, 2, 3])
#=> [1,
# 2,
# 3]
Akr-san, what do you think?
---Files--------------------------------
pp-default-maxwidth.patch (1.05 KB)
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:[email protected]?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>