Reputation: 18563
Upon opening Scala console (by simply running scala
in a terminal), one can invoke a set of commands, each of which starts with a colon :
.
One can see a list of those commands by typing :help
, which itself is one of them, in the REPL.
scala> :help
All commands can be abbreviated, e.g. :he instead of :help.
:cp <path> add a jar or directory to the classpath
:edit <id>|<line> edit history
:help [command] print this summary or command-specific help
:history [num] show the history (optional num is commands to show)
:h? <string> search the history
: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 interpreter
:replay reset execution and replay all previous commands
:reset 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> +enable/-disable flags, set compiler options
:silent disable/enable automatic printing of results
:type [-v] <expr> display the type of an expression without evaluating it
:kind [-v] <expr> display the kind of expression's type
:warnings show the suppressed warnings from the most recent line which had any
Are these commands actual Scala code or arbitrary strings that can be recognized by the REPL before the line is interpreted as Scala?
If they do belong to the Scala world, what are they syntactically? Are these simply methods following a naming convention?
Upvotes: 0
Views: 417
Reputation: 369478
They are part of the REPL syntax, not part of Scala syntax.
From the point of view of the REPL, they are syntactically commands. From the point of view of Scala, they are syntax errors.
Upvotes: 3