read-eval-print-loop

How to get the last exception object after an error is raised at a Python prompt?

99封情书 提交于 2019-11-30 06:39:51
问题 When debugging Python code at the interactive prompt (REPL), often I'll write some code which raises an exception, but I haven't wrapped it in a try / except , so once the error is raised, I've forever lost the exception object. Often the traceback and error message Python prints out isn't enough. For example, when fetching a URL, the server might return a 40x error, and you need the content of the response via error.read() ... but you haven't got the error object anymore. For example: >>>

How to see docstrings and other symbol information in Common Lisp REPL?

て烟熏妆下的殇ゞ 提交于 2019-11-30 06:31:17
I'm completely new to CL, and I'd like to learn how to read documentation strings and get other help information from the REPL. Something like help(symbol) in Python, or symbol? in iPython, or :t and :i in Haskell's GHCi. So, given a symbol name, I'd like to be able to know: what kind of value it is bound to, if any (a function, a variable, none at all) if it is a function or a macro, then what are its positional arguments if it has a docstring, show it what package or file it is coming from or when it was defined I found there is (documentation '_symbol_ '_type_) , but it is not exactly what

Start up script for node.js repl

瘦欲@ 提交于 2019-11-30 06:22:55
Is there a way configure node.js's repl? I want to require jquery and underscore automatically whenever the repl starts. Is there a file (noderc?) that node.js loads when it starts the repl? The equivalent in Python is to edit ~/.ipython/ipy_user_conf.py with: import_mod('sys os datetime re itertools functools') I don't know of any such configuration file, but if you want to have modules foo and bar be available in a REPL, you can create a file myrepl.js containing: var myrepl = require("repl").start(); ["foo", "bar"].forEach(function(modName){ myrepl.context[modName] = require(modName); });

Failed to created JLineReader (Scala REPL)

冷暖自知 提交于 2019-11-30 05:28:43
问题 When I start the REPL on Windows 7 64-bit (it works ok on my Windows XP laptop) I get the following message: Failed to created JLineReader: java.lang.NoClassDefFoundError: Could not initial ize class org.fusesource.jansi.internal.Kernel32 Falling back to SimpleReader. This means history and code completion don't work. I have googled the problem but I can't find any resolution. I don't have sbt or Maven or ivy installed so I don't think it's anything to do with those. My %SCALA_HOME% is set up

Setting package in Scala REPL

我是研究僧i 提交于 2019-11-30 05:05:31
问题 Is there a way in the Scala REPL to set the "active" package scope ? Say I have a package com.package with class A , I want to be able to type new A() instead of new com.package.A() without explicitly doing import com.package.A . There might be a number of other classes in that package I'm interested into and I don't want to polute my REPL's global namespace by doing import com.package._ . Even better, I'd like to define class A without typing its fully qualified name. Something like: package

How can I load optimized code in GHCI?

本秂侑毒 提交于 2019-11-30 04:13:44
I am writing a module that relies on optimization. I want to test this module in ghci. But starting ghc in --interactive mode automatically disables optimization; if I compile the module with -O and then try to load it in an interactive session, ghc insists on loading it in interpreted mode. For a simple test case to distinguish optimized and unoptimized modules, isOptimized below evaluates to True with optimization on, but False with optimization off: isOptimized :: Bool isOptimized = g g :: Bool g = False {-# NOINLINE g #-} {-# RULES "g/True" g = True #-} Either use ghci -fobject-code -O

haskell repl in emacs

落爺英雄遲暮 提交于 2019-11-30 00:53:29
Hi i am starting with haskell and trying to set up my emacs for its development. I have haskell-mod and ghc-mod latest in emacs 24.3.1 . GHC is 7.6.3 i have created a haskell file first.hs and when i do C-c C-l It asks : start a new project named haskell ? y or n my directory name is haskell. I press y Set the cabal directory I have tried with both ~/.cabal and my current directory named haskell Set the current directory Just pressed enter as it has haskell directory It shows error messages : haskell-process-start: cl-ecase failed: cabal-rep, (ghci quote cabal-repl quote cabal-ghci quote cabal

Is Lisp the only language with REPL?

你说的曾经没有我的故事 提交于 2019-11-29 23:35:46
There are languages other than Lisp (ruby, scala) that say they use REPL (Read, Eval, Print, Loop), but it is unclear whether what is meant by REPL is the same as in Lisp. How is Lisp REPL different from non-Lisp REPL? The idea of a REPL comes from the Lisp community. There are other forms of textual interactive interfaces, for example the command line interface . Some textual interfaces also allow a subset of some kind of programming language to be executed. REPL stands for READ EVAL PRINT LOOP: (loop (print (eval (read)))). Each of the four above functions are primitive Lisp functions. In

C# Console/CLI Interpreter?

无人久伴 提交于 2019-11-29 22:57:41
I wonder if there is something like a standalone Version of Visual Studios "Immediate Window"? Sometimes I just want to test some simple stuff, like "DateTime.Parse("blah")" to see if that works. But everytime i have to create a new console application, put in my code and test it. The Immediate Window sadly only works when I am debugging something. Could PowerShell do that? Just open a CLI similar to what cmd.exe does, allowing me to execute some C# code? Linqpad - I use it like this all the time. http://www.linqpad.net/ Don't be misled by the name - that just describes the original motivation

How do I access scala documentation from the repl?

早过忘川 提交于 2019-11-29 22:13:31
First of all for the built in docs, and also for my own code. Specifically, I want to get information similar to how in python you can call help() on a method or object to get information on just that object printed into the repl. Scaladocs are generated as HTML, so you don't want them appearing in the REPL window. You might want to load docs in a browser from the REPL, however. You can do that by creating your own method like so (this one takes an instance; you could have it take an instance of Class[A] instead, if you prefer): def viewdoc[A](a: A) { val name = a.asInstanceOf[AnyRef].getClass