[ruby-core:78081] [Ruby trunk Feature#12913] A way to configure the default maximum width of pp
From:
mame@...
Date:
2016-11-11 03:31:39 UTC
List:
ruby-core #78081
Issue #12913 has been updated by Yusuke Endoh.
Akira Tanaka wrote:
> pp (including pretty_inspect and PP.pp) method is used in many gems.
Note that my proposal is only for PP; the scope does not includes pretty_inspect.
PP is a debugging-purpose API, so it is rarely used in a released code. So, we don't have to consider the case where PP is used in multiple modules simultaneously, I think. Also, because of debugging-purpose, it would be good to prioritize usability than safety.
----------------------------------------
Feature #12913: A way to configure the default maximum width of pp
https://bugs.ruby-lang.org/issues/12913#change-61430
* 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:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>