read-eval-print-loop

In the Node.js REPL, why does this happen?

本秂侑毒 提交于 2019-12-29 07:41:30
问题 So I was playing around with the Node.js REPL and the Underscore library when I noticed something very strange. If I require("underscore") , the variable _ is set globally (obviously). Then when I attempt to run a simple command like console.log(_.isEmpty) it prints [Function] (again, obviously). However, upon running console.log(_) right after, it prints [Function] because the variable _ was set to _.isEmpty . Why does this do this? If I run the same code from a js file this doesn't happen.

Node.js REPL continuation lines

安稳与你 提交于 2019-12-24 16:59:58
问题 When working with the node.js repl, is there a way to quit a continuation line that node is being over zealous with? For example: $ node > {- -} ... And pretty much everything you can type then gives you another continuation line. Ctrl+D quits the whole repl. Obviously I don't want to go around typing {- -} all the time, but I do find I often type something erroneous when I'm using the repl to experiment. Then I have to quit the repl, and loose all the bits in memory. 回答1: You can also type:

How do I limit node repl instances so they cannot access global scope?

谁说我不能喝 提交于 2019-12-24 13:13:14
问题 When you create a new repl instance in code it automatically has access to anything in global scope. You can modify the repl context to expose some custom variables in local scope so that the repl can access them, but I don't see an easy way to eliminate access to the global scope. I wish I could just give the repl a new blank global scope. Here is an example repl instance: var repl = require('repl'), msg = "Hello world!"; repl.start('> ').context.msg = msg; In that repl I typed out the

replace string1 with string2 in many java files, only in comments

混江龙づ霸主 提交于 2019-12-24 00:05:04
问题 I have around 3000 instance of replacement done in hundreds of files. Replacing all occurance of string1 with string2 was easy. IntelliJ allows me to replace all occurences in "comments and strings". The problem is that the same string appear in comments and real code. I would like restrict the replacement only in comment section ( we use mix of /**/ or // ) Any library/IDE/script that can do this? 回答1: use Regexp::Common 'comment'; ... s/($RE{comment}{'C++'})/(my $x = $1) =~ s#string1

Is there a quick way to show the code of a method declared in the Scala Console?

霸气de小男生 提交于 2019-12-23 09:05:36
问题 I frequently use the Scala console to evaluate and test code before I actually write it down in my project. If I want to know the contents of a variable, I can just enter it and scala evaluates it. But is there also a way to show the code of methods I entered? I know there's the UP-key to show single lines, but what I was searching for is to show the whole code at once. 回答1: There's a file in your home directory named .scala_history that contains all of your recent REPL history. I regularly

Perl6 REPL usage

十年热恋 提交于 2019-12-23 09:03:11
问题 Is it possible to have (Rakudo) Perl6 execute some code before dropping you into the REPL? Like python does with "python -i ". For instance, I want to load up some modules and maybe read a side file and build some data structures from that side file before dropping into the REPL and letting the user do the things they need to do on the data structure, using the REPL as a user interface. This is similar but different than Start REPL with definitions loaded from file though answers to this

Access package private method in Scala REPL

£可爱£侵袭症+ 提交于 2019-12-23 04:15:16
问题 Suppose I have a private[stuff] method Stuff.something in org.my.stuff . Is there something that I can do in the Scala REPL so that I can call Stuff.something without getting the error error: value something is not a member of org.my.stuff.Stuff ? In particular, can I get the REPL to be "inside" a given package (here org.my.stuff ), giving access to its private members? 回答1: Using "packages" in the REPL You cannot get a REPL prompt "inside" a given package, see https://stackoverflow.com/a

Sending input to a screen window from vim

妖精的绣舞 提交于 2019-12-23 04:14:17
问题 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.

Node REPL eval Callback

烈酒焚心 提交于 2019-12-23 03:22:46
问题 I have a small sample program http://pastebin.com/5gFkaPgg that serves a REPL to a client over TCP. Acording to the docs http://nodejs.org/api/repl.html I have by eval function (lines 11-13) setup correctly, but the callback object is not a function. What am I misinterpreting in the docs? callback(null,result); ^ TypeError: object is not a function Can't Answer my own question... According to https://github.com/joyent/node/blob/master/lib/repl.js the signature is function(code, context, file,

What's a REPL process and what can I use it for? [duplicate]

孤街浪徒 提交于 2019-12-22 21:43:12
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: Relation between REPL, interpreter and compiler I've been experimenting on heroku.com with node.js and I've heard of a "REPL process" I could use for experimenting in my app’s environment. Could someone give me an overview of what it is, and how it might be applied? 回答1: REPL - As per the Wikipedia entry It's a Read Eval Print Loop. What that means for you is: It's like a console for your app. Every line you