最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

read eval print loop - Scala REPL missing commands - Stack Overflow

programmeradmin3浏览0评论

I have installed scala through coursier. Running scala --version in the terminal gives the following:

C:\Users\Me>scala --version
Scala code runner version: 1.4.3
Scala version (default): 3.5.1

When I run scala to start the REPL I get the right welcome. But this REPL seems to be missing commands. :help only returns the following:

Welcome to Scala 3.5.1 (17, Java OpenJDK 64-Bit Server VM).
Type in expressions for evaluation. Or try :help.

scala> :help
The REPL has several commands available:

:help                    print this summary
:load <path>             interpret lines in a file
:quit                    exit the interpreter
:type <expression>       evaluate the type of the given expression
:doc <expression>        print the documentation for the given expression
:imports                 show import history
:reset [options]         reset the repl to its initial state, fetting all session entries
:settings <options>      update compiler options, if possible


scala>

And when I run a command not part of this list (such as :kind, the tool I originally wanted to try, mentioned in this answer) it just returns:

scala> :kind x
Unknown command: ":kind", run ":help" for a list of commands

Was there an update to the scala REPL since the answer was posted that removed these commands?

I have installed scala through coursier. Running scala --version in the terminal gives the following:

C:\Users\Me>scala --version
Scala code runner version: 1.4.3
Scala version (default): 3.5.1

When I run scala to start the REPL I get the right welcome. But this REPL seems to be missing commands. :help only returns the following:

Welcome to Scala 3.5.1 (17, Java OpenJDK 64-Bit Server VM).
Type in expressions for evaluation. Or try :help.

scala> :help
The REPL has several commands available:

:help                    print this summary
:load <path>             interpret lines in a file
:quit                    exit the interpreter
:type <expression>       evaluate the type of the given expression
:doc <expression>        print the documentation for the given expression
:imports                 show import history
:reset [options]         reset the repl to its initial state, fetting all session entries
:settings <options>      update compiler options, if possible


scala>

And when I run a command not part of this list (such as :kind, the tool I originally wanted to try, mentioned in this answer) it just returns:

scala> :kind x
Unknown command: ":kind", run ":help" for a list of commands

Was there an update to the scala REPL since the answer was posted that removed these commands?

Share Improve this question asked Mar 14 at 5:58 MukundKSMukundKS 1351 silver badge7 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 5

To my understanding, the REPL was more or less fully re-implemented for Scala 3. Various commands were not re-implemented yet, obviously including kind . There's an issue where this is discussed here, but no specific mention of kind there.

What you can do is pass a 2.13.x scala-version to the scala command - that will limit your REPL to that old version of the language, but you would get the full feature set of the old REPL:

% scala --scala-version 2.13    
Welcome to Scala 2.13.16 (OpenJDK 64-Bit Server VM, Java 23.0.2).
Type in expressions for evaluation. Or try :help.

scala> :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, fetting 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

Useful default key bindings:
  TAB           code completion
  CTRL-ALT-T    show type at cursor, hit again to show code with types/implicits inferred.

scala> 
发布评论

评论列表(0)

  1. 暂无评论