我正在读书here https://stackoverflow.com/questions/2160355/drop-into-interpreter-during-arbitrary-scala-code-location关于使用breakIf
REPL代码中的方法进行交互式调试,但后来我发现这个帖子 https://issues.scala-lang.org/browse/SI-6435这么说break
and breakIf
被移除自ILoop
在 Scala 2.10 中。不幸的是,该帖子没有解释why该代码已被删除。
我假设这些函数已被删除,因为有更好的方法来执行此操作。如果是这样的话,有人可以启发我吗?
也许这个想法是你应该与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()
与旧款相比breakIf
API,这种方法消除了额外的间接级别if
条件(被包装成=> Boolean
)和DebugParam
/NamedParam
(这是临时包装纸,仅用于填充bind
论据)。
这种方法还允许您指定您的Settings
如所须。例如,一些 REPL 错误可以解决-Yrepl-sync but break没有给你指定的方式 https://groups.google.com/d/msg/simple-build-tool/APF5m23jWcQ/_NpUa7YAKIcJ.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)