read-eval-print-loop

Can I clean the repl?

别等时光非礼了梦想. 提交于 2019-11-29 20:51:01
I have played with a lot of code in a repl console, how can I clear it? I would like a fresh one without restarting it. Can that be done? Peter Tillemans If you want to clear the current namespace of all temporary variables and functions you declared you can use this one liner (or make a function of it) : (map #(ns-unmap *ns* %) (keys (ns-interns *ns*))) or (ns myutil) (defn ns-clean "Remove all internal mappings from a given name space or the current one if no parameter given." ([] (ns-clean *ns*)) ([ns] (map #(ns-unmap ns %) (keys (ns-interns ns))))) (ns mytest) ... make loads of junk ...

Is there a colored REPL for Clojure?

[亡魂溺海] 提交于 2019-11-29 20:37:31
I'd like to get a colored REPL for clojure code, similar to what you can do with IRB for Ruby. Are there any libraries or settings for user.clj that provide automatic coloring of the REPL? Example IRB: I do not know of any way to have the basic Clojure REPL, as started by something like java -cp clojure.jar clojure.main , do syntax highlighting. If, however, you use Emacs & SLIME (the development environment of choice of a great part of the Clojure community!), then you can have the SLIME REPL highlight syntax like clojure-mode does. First, you'll have to lift some code from the clojure-mode

REPL Environment for the Web [closed]

浪子不回头ぞ 提交于 2019-11-29 20:29:10
I'm looking to find a REPL system that can be executed on a web page and that the server can react to. Is there anything out there (I'd assume it would have to be using Javascript/AJAX)? If there's a PHP implementation, it would be even more awesome, but for now I'm just looking for some kind of an implementation. A JavaScript REPL: http://tech.einaregilsson.com/repl.html A PHP REPL developed at Facebook: http://www.phpsh.org/ A Python REPL: http://www.trypython.org/ A Ruby REPL: http://tryruby.org/ A Haskell REPL: http://tryhaskell.org/ An R REPL: http://rstudio.org/ repl.it Have you tried

handy ways to show linearization of a class?

末鹿安然 提交于 2019-11-29 20:04:07
问题 I'll bet there are some snazzy ways to show linearization in the repl via the new reflection libraries and/or repl power mode. What are they? In my particular case, I'm trying to understand the linearization of ArrayBuffer instances. (I'm trying to make a similar class that's a Buffer and an IndexedSeqOptimized, and I'm finding complaints from the compiler that overriding method seq has incompatible type) The rules for linearization of scala classes are described in the scala spec section 5.1

How to investigate objects/types/etc. from Scala REPL?

我是研究僧i 提交于 2019-11-29 19:32:32
I've been working with Scala for a while now and have written a 10,000+ line program with it, but I'm still confused by some of the inner workings. I came to Scala from Python after already having intimate familiarity with Java, C and Lisp, but even so it's been slow going, and a huge problem is the frustrating difficulty I've often found when trying to investigate the inner workings of objects/types/classes/etc. using the Scala REPL as compared with Python. In Python you can investigate any object foo (type, object in a global variable, built-in function, etc.) using foo to see what the thing

How to save REPL session?

会有一股神秘感。 提交于 2019-11-29 18:22:43
问题 Is it possible to save a REPL session in a file? Is there a minimum version of Scala requiered to do this? I remember having seen someone do it, but I can't fine it in :help or in the documentation. 回答1: This is possible as of Scala 2.11. Example usage: scala> 1 res0: Int = 1 scala> 2 res1: Int = 2 scala> 3 res2: Int = 3 scala> :save xxx scala> :load xxx Loading xxx... res3: Int = 1 res4: Int = 2 res5: Int = 3 You can :reset before a :load to get correct references to results: scala> 1 res0:

Scala REPL in Gradle

六眼飞鱼酱① 提交于 2019-11-29 17:47:11
问题 At the moment Gradle's scala integration does not offer REPL functionality. How to ergonomically run a Scala REPL from Gradle with the appropriate classpath? 回答1: Minimal build.gradle : apply plugin: 'scala' repositories{ mavenCentral() } 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 standardInput System.in args '

Can you program without REPL on Lisp?

我与影子孤独终老i 提交于 2019-11-29 15:39:54
So I just got Land of Lisp and started to do the first program. I have a couple questions. Is there a way to just write some code and run it through a compiler, or interpreter, and not use the REPL thing? I don't like it much. I can't seem to go back if I messed up. It just kinda says "Ha you screwed up, retype that whole function." I would also like to know what the point of REPL is. Non-REPL work flow Edit your file Compile the file using compile-file ; fix errors and warnings; repeat. Load the file using load ; evaluate the form you want; repeat Example $ cat > f.lisp <<EOF (defun f (x) (if

Companion object cannot access private variable on the class

…衆ロ難τιáo~ 提交于 2019-11-29 14:39:23
问题 A rather weird behavior coming from the Scala REPL. Although the following compiles without a problem: class CompanionObjectTest { private val x = 3 } object CompanionObjectTest { def testMethod(y:CompanionObjectTest) = y.x + 3 } the private variable does not seem to be accessible from the companion object in REPL: scala> class CompanionObjectTest { | | private val x = 3; | } defined class CompanionObjectTest scala> object CompanionObjectTest { | | def testMethod(y:CompanionObjectTest) = y.x

Why does typing a variable (or expression) print the value to stdout?

跟風遠走 提交于 2019-11-29 13:25:54
Take this example: >>> 5+10 15 >>> a = 5 + 10 >>> a 15 How and why does Python do this without an explicit print statement? If I do the same thing in an IPython cell, only the last such value is actually printed on stdout in this way: In[1]: 5+10 1 Out[1]: 1 Why does this happen? When Python is in "interactive" mode, it enables certain behaviors it doesn't have in non-interactive mode. For example, sys.displayhook , originally specified in PEP 217 . If value is not None, this function prints it to sys.stdout, and saves it in __builtin__._ . sys.displayhook is called on the result of evaluating