Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Console setOut suboptimal behavior #4793

Open
scabug opened this issue Jul 12, 2011 · 3 comments
Open

Console setOut suboptimal behavior #4793

scabug opened this issue Jul 12, 2011 · 3 comments

Comments

@scabug
Copy link

scabug commented Jul 12, 2011

(Email from huynhjl@gmail.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
System.setOut.

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?

--Jean-Laurent

@scabug
Copy link
Author

scabug commented Jul 12, 2011

Imported From: https://issues.scala-lang.org/browse/SI-4793?orig=1
Reporter: @paulp

@scabug
Copy link
Author

scabug commented Jul 13, 2011

huynhjl said:
I think setOutGlobally is a good idea as it would minimize code breakage.

@scabug scabug added this to the Backlog milestone Apr 7, 2017
@scala scala deleted a comment from scabug Feb 17, 2018
@SethTisue
Copy link
Member

I labeled this as "good first issue" even it isn't clear what's next here. Didn't we deprecate setOut in favor of withOut? Someone could assess the situation and make a suggestion about whether the ticket should remain open, and if so, what addressing it should look like.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants