From: Caleb Clausen Date: 2010-05-01T01:06:15+09:00 Subject: Re: Use of STDOUT.flush after puts On 4/30/10, Robert Klemme wrote: > 2010/4/30 Charles Oliver Nutter : >> On Thu, Apr 29, 2010 at 4:24 PM, Caleb Clausen wrote: >>> Check out this code. No other method in all of ruby has this behavior. >>> >>> p $stderr.class #=>IO >>> >>> f=File.new "foo","w" >>> $stderr.reopen(f) >>> >>> p $stderr.class #=>File >> >> This is a really nasty feature not a lot of people know about. It's >> not possible for us to support in JRuby because the underlying object >> can't actually change class: > > That's true, instances which change their class - this is problematic. > >> I'm of the opinion that .reopen should be discouraged in general. > > IMHO that is a bad idea because this is the standard way how you > redirect stderr, stdin and stdout for child processes - at least on > POSIX systems. Any program that wants to do something similar like > IO.popen or just wants to prevent the child's stdout to clutter its > own output depends on the ability to do this. I would hate to see reopen go away, but I have to agree with Charlie that the current implementation has some pretty ugly semantics. It seems like one ought to be able to get the same effect through creative use of singleton classes or extend....