Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
528 views
in Technique[技术] by (71.8m points)

language agnostic - One REPL to bind them all?

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...