read-eval-print-loop

How to not have Gradle quit Scala's REPL immediately?

余生长醉 提交于 2019-12-10 17:54:23
问题 These simple lines in build.gradle expose a repl task that would ideally fire up a scala REPL. Fire up and keep alive that is. After the repl loads, it immediately receives a :quit command and exits. Important parts of build.gradle : dependencies{ compile "org.scala-lang:scala-library:2.11.7" compile "org.scala-lang:scala-compiler:2.11.7" } task repl(type:JavaExec) { main = "scala.tools.nsc.MainGenericRunner" classpath = sourceSets.main.runtimeClasspath } Launching the REPL: % gradle repl

scala: tracing implicits selection and other code magics

馋奶兔 提交于 2019-12-10 17:24:37
问题 When trying to figure how a library works, implicit conversions are confusing. For example, looking at an expression like 'val foo: Foo = 1', what converts 1 to Foo? Is it possible to instruct the scala library (or REPL) to print out the code paths that are executing while evaluating an expression? 回答1: You can add "-Xprint:typer" to the compiler command line (or "-Ybrowse:typer" for a swing GUI browser) to see the code with the conversions explicitly applied. 回答2: As an alternative to

Why and how do you use JShell?

与世无争的帅哥 提交于 2019-12-10 03:45:56
问题 I went through a couple of tutorials for JShell and I still do not understand the most important part: why would I even use JShell? Here what Oracle says: "You can test individual statements, try out different variations of a method, and experiment with unfamiliar APIs within the JShell session". Yes, great, but for all those things I can just use an IDE. I do understand, that REPL should make code evaluation faster. However, testing a snippet of code in IDE in a dummy Hello World project

Launch Scala REPL programmatically?

こ雲淡風輕ζ 提交于 2019-12-09 15:18:18
问题 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? 回答1: 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

Clojure : 'lein repl' history grepping?

孤街浪徒 提交于 2019-12-08 17:19:11
问题 I often find myself executing commands like this at bash : history | grep 'find' For example to look up a fancy find / xargs command i might have ran. Im wondering --- where does the "lein repl" store its historical data ? It would be nice to know, because then I could write a leingrep.sh script, which simply grepped through the lein history session. It is obvious that this is on disk somewhere, since history is preserved from one repl to the next. 回答1: Lein is using either readline (if you

Sending input to a screen window from vim

点点圈 提交于 2019-12-08 17:00:46
I have a vim function set up where I can highlight a line of text and execute in clojure. Here's the function: function! Clojure_execline() let cl = (getline(line("."))) // ... exec 'clojure -e "' . cl . '"' endfunction The problem with this is that it's slow to start and because it spawns a new clojure session every time I run it, I can't call a function I ran previously. Ideally, I'd like for a hidden repl to be running where I could send input from vim and retrieve the output from as well. I learned about gnu screen and thought it could help me, but I don't know how to send input from one

Is there an equivalent to the perl debugger 'x' in pdl2 (or Devel::REPL)?

你。 提交于 2019-12-08 16:41:59
问题 I am using pdl2 (the PDL shell) also as a my default Perl interactive shell (it loads all the nice plugins for Devel::REPL). But I am missing the x dumper-printing alias. p is nice for piddles but it does not work for a normal array ref or hash ref. I have loaded Data::Dumper but it lacks an easy way of controlling depth and I like the way you can quickly set depth limits with x , e.g. x 2 $deep_datastruct for complex data structures. But with Data::Dumper the process is more cumbersome: pdl>

How to run existing Clojure programme in Sublime REPL

本秂侑毒 提交于 2019-12-08 13:11:50
问题 I have setup sublime REPL(Sublime 2, MAC) and able to run small Clojure programs like (+ 2 2) . I have created a small project using lein lein new app clojure-noob and I am able to run it via lein repl . And it loads the main class defined inside the project. How can I load the same main class in Sublime REPL. 回答1: All you need to do is open your project's project.clj file in Sublime, make sure it has focus, then select Tools → SublimeREPL → Clojure → Clojure . This runs lein repl in project

How can I easily write a REPL app in Java?

扶醉桌前 提交于 2019-12-08 00:50:01
问题 I have a CMS server that provides a client library. I'd like to be able to drive the CMS interactively from the command line. The basic approach would be: Create a connection to the CMS Add the CMS connection object to the REPL context Connect the REPL to stdout/stderr/stdin Kick off a daemon thread for to keep the REPL running. I was hoping that I could perhaps leverage Groovy to do this but haven't managed to get it working. Is there a library that provides REPL support? Can you provide a

How to get suppress ^M characters in my ClojureBox (EmacsW32) REPL connected to lein swank

最后都变了- 提交于 2019-12-07 17:20:14
问题 I am connecting to a swank server from my ClojureBox install. I.e. lein swank from my project directory and then M-x slime-connect from EmacsW32. However, when I do this I see the DOS line-endings everywhere in the REPL ( ^M ). I.e. user> (doc map) -------------------------^M clojure.core/map^M ([f coll] [f c1 c2] [f c1 c2 c3] [f c1 c2 c3 & colls])^M Returns a lazy sequence consisting of the result of applying f to the set of first items of each coll, followed by applying f to the set of