我在这里阅读有关breakIf在REPL代码中使用该方法进行交互式调试的信息,但后来我发现这篇帖子说break并在Scala 2.10 breakIf中删除了ILoop.不幸的是,该帖子并未解释为何删除了代码.
我假设删除了这些函数,因为有更好的方法可以做到这一点.如果是这样的话,有人可以赐教我吗?
也许这个想法是你应该ILoop直接与之合作?据我所知,它不应该比以下复杂得多:
// insert the code below wherever you want a REPL
val repl = new ILoop
repl.settings = new Settings
repl.in = SimpleReader()
repl.createInterpreter()
// bind any local variables that you want to have access to
repl.intp.bind("i", "Int", i)
repl.intp.bind("e", "Exception", e)
// start the interpreter and then close it after you :quit
repl.loop()
repl.closeInterpreter()
Run Code Online (Sandbox Code Playgroud)
与旧的breakIfAPI 相比,这种方法消除了if条件(包含在a中=> Boolean)和DebugParam/ NamedParam(它们是仅用于填充bind参数的临时包装器)的额外级别的间接.
此方法还允许您Settings根据需要指定.例如,一些REPL错误可以解决,-Yrepl-sync但break没有办法指定.
| 归档时间: |
|
| 查看次数: |
1161 次 |
| 最近记录: |