Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Launch Scala REPL programmatically?

I would like to launch a Scala Swing application from the command line, then after the application is started, drop into the Scala REPL to use as a control interface.

Ideally I would also like to pre-bind some variable names. Even better would be using a Java2D terminal emulator for the REPL, but I couldn't find anything appropriate.

Does the Scala REPL have a public API?

like image 279
David Crawshaw Avatar asked Mar 16 '10 18:03

David Crawshaw


People also ask

How do I launch a scala REPL?

We can start Scala REPL by typing scala command in console/terminal.

Does scala have REPL?

The Scala REPL is a tool (scala) for evaluating expressions in Scala. The scala command will execute a source script by wrapping it in a template and then compiling and executing the resulting program.

What is scala REPL?

The Scala REPL (Read-Eval-Print-Loop) is a development tool to interpret fragments of Scala code. It doesn't require too much setup or infrastructure and it is going to be essential during your learning journey. Using the REPL, you'll be able to play and experiment with the language by typing and evaluating code.

How do I get scala prompt?

To run Scala from the command-line, download the binaries and unpack the archive. Start the Scala interpreter (aka the “REPL”) by launching scala from where it was unarchived. Start the Scala compiler by launching scalac from where it was unarchived.


1 Answers

You are may be asking about the same thing, as this question, are you? There is other stuff you can do. There's a way to just call REPL with a code, and get an answer back, which, depending on what you want, may be more appropriate. If that's what you want, just clarify it and I'll research into it.

As for Java2D terminal, I think it is enough to use Console's setIn, setOut and setErr, but I might be mistaken. You might want to take a look at how some other efforts which embed REPL in the environment do. I think there are at least three of them, but a quick search only Kojo, which is based on Netbeans.

like image 170
Daniel C. Sobral Avatar answered Oct 04 '22 20:10

Daniel C. Sobral