From: merch-redmine@... Date: 2017-11-30T21:41:18+00:00 Subject: [ruby-core:84015] [Ruby trunk Feature#14123] Kernel#pp by default Issue #14123 has been updated by jeremyevans0 (Jeremy Evans). Eregon (Benoit Daloze) wrote: > Right, multiple calls to `require "pp"` will wait for one another and only one will actually load the file. > This didn't look thread-safe at first look but it seems fine with require's guarantees (assuming people only do require "pp", no #load but that sounds unlikely). What happens in the following circumstance: * Thread 1 calls `Kernel#pp`, defined in prelude, which requires 'pp'. * During requiring of pp: ~~~ undef pp if method_defined?(:pp) # Thread switch here def pp(*objs) ~~~ * Thread 2 calls `Kernel#pp` during thread switch Unless the thread switch is completely blocked during the execution of required code, it seems like this is still not thread safe. ---------------------------------------- Feature #14123: Kernel#pp by default https://bugs.ruby-lang.org/issues/14123#change-68096 * Author: mame (Yusuke Endoh) * Status: Closed * 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: