interpreter

Avoiding the infamous “eval(parse())” construct

我只是一个虾纸丫 提交于 2019-11-27 08:03:47
Ok, so I'm running some loops to process data stored in list objects. Ever mindful of the infamous fortune admonishment not to use eval(parse(mystring)) , I came up with this: Rgames> bar $foo $foo$fast [1] 1 2 3 4 5 $foo$slow [1] 6 7 8 9 10 $oof $oof[[1]] [1] 6 7 8 9 10 $oof[[2]] [1] 1 2 3 4 5 Rgames> rab<-'bar' Rgames> do.call('$',list(as.name(rab),'oof')) [[1]] [1] 6 7 8 9 10 [[2]] [1] 1 2 3 4 5 Typically I'd be selecting a list (of which bar is one such) and then one element of the list (e.g. oof ) which contains my data. The code above does the same thing as eval(parse(text=paste(rab,'$',

Suggestions for writing a programming language? [closed]

↘锁芯ラ 提交于 2019-11-27 07:28:59
What tips can you give a person who is looking to write a programming or script language? I am not worried about how to program nor design a compiler but how to develop one quickly using tools and code generators. Last time i tried i coded it in c++ and the states and syntax took almost as long as writing the actual logic. I know the follow tools would help. I was thinking i could generate c++ code and have gcc compile that. Using the tools above how long would you estimate it would take to write a program or script language? Variations on this question have been asked repeatedly, as far back

Load Scala file into interpreter to use functions?

点点圈 提交于 2019-11-27 07:02:21
I have some Scala functions defined in a file, not in a class, and I would like to use them in the Scala interpreter. I know I can say scala filename.scala to simply run the file and exit the interpreter, but I would like to run the file and then stay in the interpreter so I can do some testing. Can anyone tell me how to simply load a file into the interpreter so I can use the functions defined within it? type :load /path/to/file in Scala REPL. You can get complete list of available commands by typing :help Suresh Babu On occasions, :paste might be your better friend (than :load ). Here is an

Python Compilation/Interpretation Process

邮差的信 提交于 2019-11-27 06:07:44
I'm trying to understand the python compiler/interpreter process more clearly. Unfortunately, I have not taken a class in interpreters nor have I read much about them. Basically, what I understand right now is that Python code from .py files is first compiled into python bytecode (which i assume are the .pyc files i see occasionally?). Next, the bytecode is compiled into machine code, a language the processor actually understands. Pretty much, I've read this thread Why python compile the source to bytecode before interpreting? Could somebody give me a good explanation of the whole process

Does Pycharm have Interactive Python Interpreter?

你。 提交于 2019-11-27 05:28:08
问题 I am a fairly new Pycharm user switched from other IDEs recently. One question I have is about the interactive python interpreter, which is the "window" I can type in variables to check them after I ran my script. Pyscripter has this thing called "Python interpreter" and I know Pycharm also has. I tried "Python Console" under "Tools", but I don't think it's the same thing. So I am wondering how I can find this Python Interpreter in Pycharm? I am using Community version 3. 回答1: I'm using

Do comments slow down an interpreted language?

被刻印的时光 ゝ 提交于 2019-11-27 04:34:44
I am asking this because I use Python, but it could apply to other interpreted languages as well (Ruby, PHP, JavaScript). Am I slowing down the interpreter whenever I leave a comment in my code? According to my limited understanding of an interpreter, it reads program expressions in as strings and then converts those strings into code. It seems that every time it parses a comment, that is wasted time. Is this the case? Is there some convention for comments in interpreted languages, or is the effect negligible? For the case of Python, source files are compiled before being executed (the .pyc

C++ interpreter / console / snippet compiler

北战南征 提交于 2019-11-27 03:37:16
问题 I am looking for a program where I can enter a C++ code snippet in one window, press a button, and get output in another window. Compilation should somehow be hidden behind the button. On a per-snippet basis would be fine, full interactive probably asking too much. It should run under Linux/Unix. Main use case would be learning/testing/short debugging, etc. Related stuff I found: -- the Reinteract project for python (which i'm told sage has features similar to) -- the same thread for C# here:

Printing Unicode from Scala interpreter

牧云@^-^@ 提交于 2019-11-27 03:09:03
问题 When using the scala interpreter (i.e. running the command 'scala' on the commandline), I am not able to print unicode characters correctly. Of course a-z, A-Z, etc. are printed correctly, but for example € or ƒ is printed as a ?. print(8364.toChar) results in ? instead of €. Probably I'm doing something wrong. My terminal supports utf-8 characters and even when I pipe the output to a seperate file and open it in a texteditor, ? is displayed. This is all happening on Mac OS X (Snow Leopard,

AST interpreter?

隐身守侯 提交于 2019-11-27 01:41:43
问题 I have an AST (abstract syntax tree) and now i want to test my compiler by giving it 2 or more numbers and expect an output with the result of math operations (like a calculator). My question is, what is the best way to build the interpreter? The visiting of the AST nodes is recursive, so i don't know how many encapsulated calculations exists until i get to the end of the tree. But since this is done iteration by iteration, how can i make all the operations in the end? Thank you 回答1:

Is Ruby really an interpreted language if all of its implementations are compiled into bytecode?

雨燕双飞 提交于 2019-11-27 01:22:13
问题 In the chosen answer for this question about Blue Ruby, Chuck says: All of the current Ruby implementations are compiled to bytecode. Contrary to SAP's claims, as of Ruby 1.9, MRI itself includes a bytecode compiler, though the ability to save the compiled bytecode to disk disappeared somewhere in the process of merging the YARV virtual machine. JRuby is compiled into Java .class files. I don't have a lot of details on MagLev, but it seems safe to say it will take that road as well. I'm