-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Implement :settings in the REPL #13982
Conversation
5923bfe
to
cfa358b
Compare
@griggt @som-snytt do either (or both!) of you want to help review and merge this, please? |
|
I don't remember the behavior of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An essential command! Puts the REPL on a firm setting.
Well that makes it harder, because it actually doesn't:
Yeah, it's not that in Scala 3. But I wouldn't be against someone proposing that change. |
Thanks for the tweak (to the code). If I didn't mention, I noticed that some settings are cached so setting in Scala 2 repl doesn't take. |
@griggt happy for this to land or do you still want to look at it first? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I should have time tomorrow to review in more detail. Some initial comments:
- it would be nice to add
:settings
to the REPL:help
display - is the behavior shown below expected?
$ mkdir -p /tmp/{a,b}
$ ./bin/scala
scala> :settings -d /tmp/a
scala> val x = 42
val x: Int = 42
scala> class Foo
// defined class Foo
$ ./bin/scala
scala> val x = 42
val x: Int = 42
scala> :settings -d /tmp/b
scala> class Foo
Exception in thread "main" java.lang.ClassNotFoundException: repl$.rs$line$2$
at dotty.tools.repl.AbstractFileClassLoader.findClass(AbstractFileClassLoader.scala:49)
at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
at dotty.tools.repl.AbstractFileClassLoader.loadClass(AbstractFileClassLoader.scala:55)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:348)
at dotty.tools.repl.Rendering.load$1(Rendering.scala:147)
at dotty.tools.repl.Rendering.forceModule(Rendering.scala:149)
at dotty.tools.repl.ReplDriver.extractAndFormatMembers$1(ReplDriver.scala:328)
at dotty.tools.repl.ReplDriver.renderDefinitions$$anonfun$2(ReplDriver.scala:349)
at scala.Option.map(Option.scala:242)
at dotty.tools.repl.ReplDriver.renderDefinitions(ReplDriver.scala:352)
at dotty.tools.repl.ReplDriver.compile$$anonfun$2(ReplDriver.scala:271)
at scala.util.Either.fold(Either.scala:189)
at dotty.tools.repl.ReplDriver.compile(ReplDriver.scala:287)
at dotty.tools.repl.ReplDriver.interpret(ReplDriver.scala:221)
at dotty.tools.repl.ReplDriver.loop$1(ReplDriver.scala:155)
at dotty.tools.repl.ReplDriver.runUntilQuit$$anonfun$1(ReplDriver.scala:158)
at dotty.tools.repl.ReplDriver.withRedirectedOutput(ReplDriver.scala:177)
at dotty.tools.repl.ReplDriver.runUntilQuit(ReplDriver.scala:158)
at dotty.tools.repl.ReplDriver.tryRunning(ReplDriver.scala:120)
at dotty.tools.repl.Main$.main(Main.scala:6)
at dotty.tools.MainGenericRunner$.run$1(MainGenericRunner.scala:177)
at dotty.tools.MainGenericRunner$.main(MainGenericRunner.scala:239)
at dotty.tools.MainGenericRunner.main(MainGenericRunner.scala)
7349e76
to
eefacf0
Compare
Som the magician foresaw it: some settings are cached (like outputDir in the REPL rendering classloader). |
eefacf0
to
4b7175f
Compare
Needed this again, today (wanted to see |
No description provided.