简体   繁体   English

scala REPL的启动脚本

[英]Startup script for scala REPL

What is the name of startup script for the scala REPL. scala REPL的启动脚本名称是什么。 For example something along the lines of the following: 例如,以下内容:

~/.scalarc 

You could try something like: 你可以尝试类似的东西:

$ alias scala='scala -i ~/.scalarc '

Note the trailing space—if you omit it your alias will disregard parameters. 注意尾随空格 - 如果省略它,你的别名将忽略参数。

Further use of 'scala' (once the alias is defined) will work as expected for REPL. 进一步使用'scala'(一旦定义了别名)将按预期用于REPL。 If you use the alias for launching compiled programs, '~/.scalarc' will simply be ignored. 如果使用别名启动已编译的程序,则只会忽略'〜/ .scalarc'。

edit : It seems using '-i' in this way causes a significant slowdown. 编辑 :似乎以这种方式使用'-i'会导致显着减速。
The following, though somewhat convoluted (warning: bashism ahead), works faster: 以下虽然有点复杂(警告:前面的玄机),但速度更快:

$ scala -i <( cat ~/.scalarc foo.scala)

This concatenates your code (eg 'foo.scala') with '.scalarc' and evaluates everything on startup, leaving you at the REPL. 这会将您的代码(例如'foo.scala')与'.scalarc'连接起来,并在启动时评估所有内容,使您处于REPL状态。
I don't think it's a satisfactory solution, but worth mentioning. 我不认为这是一个令人满意的解决方案,但值得一提。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM