一个 REPL 来绑定它们?

发布于 2024-10-31 16:57:06 字数 685 浏览 2 评论 0原文

我想知道是否有一个不特定于语言的 REPL 。我花了很多时间反复研究 REPL(主要是 Clojure、Scala 和 Haskell),而捆绑的 REPL 或多或少都让我感到沮丧。 REPL 的工作似乎非常通用,因为它们:

  • 读取:获取用户输入
  • 评估:将输入传递给某个运行时进行处理
  • 打印:将结果打印到屏幕
  • 循环:等待下一个用户输入

我不这样做明白为什么不应该有一些与语言无关的 REPL,但我一直找不到这样的东西。我希望在理想的 REPL 中实现以下功能:

  • Linux 命令行应用程序
  • 通过向上箭头可访问无限历史记录
  • 能够在重新运行
  • ctrl-r 进行历史搜索之前编辑以前的命令 像 bash
  • 在一个 REPL 中具有 多个会话,因此我可以轻松地在它们之间切换

并且更乐观地

  • 语法突出显示、上下文感知代码补全

这个存在吗?

I'd like to know if there is a REPL which is not language-specific. I spend a lot of time dipping in and out of REPLs (mainly for Clojure, Scala and Haskell), and the bundled ones all frustrate me to a greater or lesser extent. It seems like the job of a REPL is quite generic in that they:

  • Read: take user input
  • Evaluate: pass the input to some runtime for processing
  • Print: print the results to the screen
  • Loop: wait for the next user input

I don't see why there shouldn't be some language-agnostic REPL, but I have been unable to find such a thing. Some things I would like in my ideal REPL:

  • Linux command-line application
  • Infinite history accessible through the up arrow
  • Ability to edit previous commands before re-running
  • ctrl-r for history search like bash has
  • Multiple sessions in one REPL, so I can switch between them easily

And more optimistically

  • syntax highlighting, context-aware code completion

Does this exist?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

只是一片海 2024-11-07 16:57:06

Bash 对 Cr 一无所知:它使用 readline 以及向上箭头历史记录来完成此操作。听起来您正在寻找的 REPL 是 readline ?只需在您想要类似 REPL 行为的命令前面添加 rlwrap (如果没有,请安装它 - 非常棒),然后就可以开始了。

$ rlwrap java -jar clojure.jar

Bash doesn't know anything about C-r: it uses readline, which does that, as well as up-arrow history, for it. It sounds like the REPL you're looking for is readline? Just prefix the command you want REPL-like behavior from with rlwrap (install it if you don't have it - it's great), and you should be good to go.

$ rlwrap java -jar clojure.jar
沦落红尘 2024-11-07 16:57:06

Scala 2.9 REPL 将支持 CTRL-R 反向搜索。每晚构建已经具备了这一点。上下文感知选项卡完成已经有一段时间了(尽管它可以改进)。

将 scala 与 rlwrap 一起使用时,请使用 -Xnojline 标志:

rlwrap scala -Xnojline

这可以防止 jline 干扰 rlwrap。然后 rlwrap 可以自由地使用 readline 来实现光标移动和历史记录,但这是在解释器看到该行之前,您将无法进行语言感知的补全。

我希望Scala REPL能够得到改进。

  • 2.9 中有一个演示编译器,我认为它用于突出显示错误和完成等功能。
  • scala 2.9 使用的 jline 能够利用 jansi 使用 ansi 颜色,

所以我可以梦想有一天我会Scala REPL 中具有 IDE 级别的功能。实际上,这需要大量的努力,并且添加这些功能肯定比改进 Eclipse 支持的优先级要低……此外,在 Eclipse 中添加 REPL 支持可能更有意义。

Scala 2.9 REPL will have CTRL-R reverse search support. The nightly builds have that already. There has been context aware tab completion for a while (though it could be improved).

When using scala with rlwrap, use the -Xnojline flag:

rlwrap scala -Xnojline

That prevents jline from interfering with rlwrap. Then rlwrap is free to use readline to implement cursor motions and history but that is before the interpreters sees the line and you won't have language-aware completion.

I hope that the Scala REPL will be improved.

  • There is a presentation compiler that is part of 2.9 which I think is used for things like highlighting errors and completion.
  • The jline used by scala 2.9 is capable of using ansi colors leveraging jansi

So I can dream that one day I will have IDE level feature in the Scala REPL. Realistically, it would require substantial effort and adding these features is surely lower priority than improving eclipse support for instance... Besides it may make more sense to add REPL support in eclipse.

荭秂 2024-11-07 16:57:06

虽然严格来说不是 REPL,但 Seco 提供了一个笔记本式 shell,可以计算任何表达式中的表达式具有 JSR-223 绑定的语言。这个快速增长的列表包括 Javascript 等语言、Scheme、Python、Ruby、Clojure、Groovy 和 Prolog。

Seco 的灵感来源是 Mathematica 笔记本前端,原则上可以计算任何语言的表达式,尽管它需要一些工作来实现这一目标。

While not strictly speaking a REPL, Seco offers a notebook-style shell that can evaluate expressions in any language with a JSR-223 binding. This rapidly growing list includes languages like Javascript, Scheme, Python, Ruby, Clojure, Groovy and Prolog.

Seco's inspiration, the Mathematica notebook front-end, can in principle evaluate expressions in any language although it takes some work to make that happen.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文