【发布时间】:2023-11-22 18:02:01
【问题描述】:
在 python 中,我可以运行一个脚本并在该脚本的上下文中进入交互模式。这让我弄乱了全局变量以及不检查程序状态的内容。
$ python -i hello.py
我可以用 Coffeescript 做到这一点吗?我尝试了以下方法:
$ coffee -i hello.coffee
不加载 hello.coffee。相当于咖啡-i
$ cat hello.coffee | coffee -i
在 REPL 中逐行运行脚本,但在 EOF 之后结束 REPL。
【问题讨论】:
-
来自*.com/a/13386057/149330:使用
cat hello.coffee - | coffee -
它不是你要找的东西,但是把它写成一个模块然后用
require在正常的repl模式下加载它怎么样? -
这是不使用coffeescript imo的唯一真正原因。需要能够从脚本调用coffeescript repl。你可以使用源映射 n 东西,但它有点尴尬
标签: coffeescript interactive read-eval-print-loop