Issue #14123 has been updated by Eregon (Benoit Daloze).


jeremyevans0 (Jeremy Evans) wrote:
> I'm not opposed to this feature, but the proposed implementation is not thread-safe, and also breaks when running ruby chrooted.  If `Kernel#pp` is implemented, I request the implementation be thread-safe and that it fall back to `Kernel#p` if requiring `pp` fails.

The thread safety problem is due to `undef`, right?
Requiring the same file is thread-safe.
So maybe we just need to hide the redefinition warning (e.g. by setting $VERBOSE) during the require call?

Regarding visibility, #pp should be a module_function of Kernel like #p.

----------------------------------------
Feature #14123: Kernel#pp by default
https://bugs.ruby-lang.org/issues/14123#change-67883

* Author: mame (Yusuke Endoh)
* Status: Open
* Priority: Normal
* Assignee: matz (Yukihiro Matsumoto)
* Target version: 2.5
----------------------------------------
Matz, may I commit this?  I really want this.

```
diff --git a/prelude.rb b/prelude.rb
index 7b98e28285..87f49ac9fb 100644
--- a/prelude.rb
+++ b/prelude.rb
@@ -141,3 +141,11 @@ def irb
     irb
   end
 end
+
+module Kernel
+  def pp(*objs)
+    undef :pp
+    require 'pp'
+    pp(*objs)
+  end
+end
```



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