(Email from email@example.com to scala-user.)
[paulp says: I think this would be hard to change. What about a new method like setOutGlobally?]
I've noticed that Console.setOut behaves differently than
Console.setOut only affects the current thread while System.setOut
affects the whole JVM. The scaladoc does not indicate that setOut is
restricted to the current thread and I presume most callers would be
surprised by that behavior. Additionally the REPL spawns a thread when
interpreting each line, so Console.setOut does not persist.
I did a bit of investigation and I'm guessing that the change was made
so that Console.withOut would behave properly in a multi-threaded
context. See https://lampsvn.epfl.ch/trac/scala/changeset/6858.
Could setOut be reimplemented so that it affects the whole JVM while
retaining the withOut semantic to override it during a thunk
execution? (along the line of making outVar a var and having setOut
reassigning it to a new DynamicVariable). Or do you think the current
approach is better?