some Scala 2 REPL commands should be "deprecated" if not implemented in Scala 3
as discussed with @Gedochao at Scala core meeting today
in reference to e.g. https://github.com/scala/scala3/issues/21657 about Scala 2's :sh command, but there are probably other such commands as well
if I understand correctly, the idea isn't to slate anything for actual removal from Scala 2, but just have unimplemented-in-3 commands print a one-line warning (on first use in a session, but not again in that session) that the command is unimplemented in Scala 3
and I suggest we also make this distinction show up in :help, which currently looks like
scala 2.13.16> :help
All commands can be abbreviated, e.g., :he instead of :help.
:help [command] print this summary or command-specific help
:completions <string> output completions for the given string
:imports [name name ...] show import history, identifying sources of names
:implicits [-v] show the implicits in scope
:javap <path|class> disassemble a file or class name
:line <id>|<line> place line(s) at the end of history
:load <path> interpret lines in a file
:paste [-raw] [path] enter paste mode or paste a file
:power enable power user mode
:quit exit the REPL
:replay [options] reset the REPL and replay all previous commands
:require <path> add a jar to the classpath
:reset [options] reset the REPL to its initial state, forgetting all session entries
:save <path> save replayable session to a file
:sh <command line> run a shell command (result is implicitly => List[String])
:settings <options> update compiler options, if possible; see reset
:silent disable/enable automatic printing of results
:type [-v] <expr> display the type of an expression without evaluating it
:kind [-v] <type> display the kind of a type. see also :help kind
:warnings show the suppressed warnings from the most recent line which had any
off the top of my head: I think we could have two sections, the first would be the core commands that both REPLs support, then a second section with the rest
It makes more sense for Scala 3 to say "sorry, I don't support that useful Scala 2 command".
If a command isn't useful, it should be removed.
Is :javap useful? I use it daily to see what the compiler actually did. But the PR is stuck in dotty.
I agree that it's a nuisance when scala 3 doesn't support the same options as scala 2. It would be nice, but unreasonable, to hold REPL to a higher compatibility standard.
It makes more sense for Scala 3 to say "sorry, I don't support that useful Scala 2 command".
yes! the idea is to do that too, at least for :sh, which will suggest sys.process instead. perhaps there are other commands that could be treated similarly
If a command isn't useful, it should be removed.
hmm.... although that sounds appealing in theory, in practice I don't think it's really that simple (no existing command has literally zero usefulness), and removing things from 2 without a strong motivation just risks annoying people
another thought: even separately from the 2 vs 3 considerations, I think having the help text in two sections (core commands and additional commands) is probably a UX improvement. here's the things you should definitely know, and here are some additional things that might also interest you
Is :javap useful? I use it daily to see what the compiler actually did. But the PR is stuck in dotty.
yeah, that's unfortunate. I've long intended to try to get it over the finish line :-/
annoying people
That is called "telemetry". (Joke from yesterday's walk outside.)
:sh, which will suggest sys.process
maybe suggest amm
or, :amm command to swap out the repl with ammonite.
as per https://github.com/scala/scala3/issues/21660 , :paste is one of the commands that won't be implemented in Scala 3 and is now mostly extraneous in Scala 2, as per https://github.com/scala/scala3/issues/21660 and https://users.scala-lang.org/t/solved-cannot-use-paste-in-scala3-repl
I say "mostly" extraneous in Scala 2 because I think we compiler developers sometimes use :paste -raw to bypass the REPL wrapping