read-eval-print-loop

c# execute a string as code

帅比萌擦擦* 提交于 2019-11-27 06:16:44
问题 Here is what i want to do, and i know it is possible with perl, php, python and java, but i am working with c# how can i do the following: public void amethod(string functionName) { AVeryLargeWebServiceWithLotsOfMethodsToCall.getFunctionName(); } I want to pass the functionName to the method and I want it to be executed as above. How this can be done? Do i need ANTLR or any other tool for this? Thanks. 回答1: You can execute a method by name via Reflection. You need to know the type, as well as

Does Go provide REPL?

自闭症网瘾萝莉.ら 提交于 2019-11-27 05:58:29
The interactive environment is VERY helpful for a programmer. However, it seems Go does not provide it. Is my understanding correct? Mostafa No, Go does not provide a REPL. However, as already mentioned, Go Playground (this is the new URL) is very handy. The Go Authors are also thinking about adding a feature-rich editor to it. If you want something local, consider installing hsandbox . Running it simply with hsandbox go will split your terminal screen (with screen ) where you can write code at the top and see its execution output at the bottom on every save. There was a gotry among standard

Why is it possible to declare variable with same name in the REPL?

雨燕双飞 提交于 2019-11-27 05:12:50
scala> val hi = "Hello \"e" hi: String = Hello "e scala> val hi = "go" hi: String = go Within same REPL session why its allowing me to declare variable hi with same name ? scala> hi res1: String = go scala> hi="new" <console>:8: error: reassignment to val hi="new" ^ This error i understood we cannot reassign val The interesting design feature of the REPL is that your two definitions are translated to: object A { val greeting = "hi" } object B { val greeting = "bye" } A subsequent usage will import the last definition: object C { import B.greeting val message = s"$greeting, Bob." // your code }

Is there something like python's interactive REPL mode, but for Java?

元气小坏坏 提交于 2019-11-27 02:32:10
Is there something like python's interactive REPL mode, but for Java? So that I can, for example, type InetAddress.getAllByName( localHostName ) in a window, and immediately get results, without all this public static void nightmare() thing? edit Since Java 9 there's JShell Original answer follows You can also use Groovy Console . It is an interactive console where you can do what you want. Since Groovy also includes classes from the core java platform, you'll be able to use those classes as well. It looks like this: Eclipse has a feature to do this, although it's not a loop. It's called a

How can I use swift in Terminal?

…衆ロ難τιáo~ 提交于 2019-11-27 02:27:34
I read What's new in Xcode 6 . The article introduces some new feature about Xcode 6, and it says: Command Line Xcode’s debugger includes an interactive version of the Swift language, known as the REPL (Read-Eval-Print-Loop). Use Swift syntax to evaluate and interact with your running app or write new code in a script-like environment. The REPL is available from within LLDB in Xcode’s console, or from Terminal. I want to know how to get the REPL? sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer then you can do one of these: xcrun swift lldb --repl As of Xcode 6.1 - typing

Why can't I print from background threads in Clojure Cider REPL in emacs?

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-27 02:00:10
问题 If I try to evaluate the following code in my emacs cider-repl, nil is returned, as expected, but none of the printing takes place in the repl buffer or console. How can I make this print out as intended? (dotimes [i 5] (.start (Thread. (fn [] (Thread/sleep (rand 500)) (println (format "Finished %d on %s" i (Thread/currentThread))))))) ;=> nil This works fine, however: (println (format "Finished 1 on %s" (Thread/currentThread))) ;=> Finished 1 on Thread[nREPL-worker-18,5,main] -----------

Assigning a value to single underscore _ in Python/IPython interpreter

﹥>﹥吖頭↗ 提交于 2019-11-27 00:49:39
问题 I created this function in Python 2.7 with ipython : def _(v): return v later if I call _(somevalue) , I get _ = somevalue . in[3]: _(3) out[3]: 3 in[4]: print _ out[4]: 3 The function has disappeared! If I call _(4) I get: TypeError: 'int' object is not callable` Why? What's wrong with this function? 回答1: The Python interpreter assigns the last expression value to _ . This behaviour is limited to the REPL interpreter only, and is intended to assist in interactive coding sessions: >>> import

How can I start an interactive console for Perl?

旧城冷巷雨未停 提交于 2019-11-26 23:46:39
问题 How can I start an interactive console for Perl, similar to the irb command for Ruby or python for Python? 回答1: You can use the perl debugger on a trivial program, like so: perl -de1 Alternatively there's Alexis Sukrieh's Perl Console application, but I haven't used it. 回答2: Not only did Matt Trout write an article about a REPL, he actually wrote one - Devel::REPL I've used it a bit and it works fairly well, and it's under active development. BTW, I have no idea why someone modded down the

Is there something like python's interactive REPL mode, but for Java?

社会主义新天地 提交于 2019-11-26 23:20:01
问题 Is there something like python's interactive REPL mode, but for Java? So that I can, for example, type InetAddress.getAllByName( localHostName ) in a window, and immediately get results, without all this public static void nightmare() thing? 回答1: edit Since Java 9 there's JShell Original answer follows You can also use Groovy Console. It is an interactive console where you can do what you want. Since Groovy also includes classes from the core java platform, you'll be able to use those classes

In Python interpreter, return without “ ' ”

点点圈 提交于 2019-11-26 22:45:40
In Python, how do you return a variable like: function(x): return x Without the 'x' ( ' ) being around the x ? In the Python interactive prompt, if you return a string, it will be displayed with quotes around it, mainly so that you know it's a string. If you just print the string, it will not be shown with quotes (unless the string has quotes in it). >>> 1 # just a number, so no quotes 1 >>> "hi" # just a string, displayed with quotes 'hi' >>> print("hi") # being *printed* to the screen, so do not show quotes hi >>> "'hello'" # string with embedded single quotes "'hello'" >>> print("'hello'")