interpreter

Difference between a Java interpreter and JVM

心已入冬 提交于 2019-12-03 07:27:48
问题 I have heard people saying "a JVM is necessarily a Java interpreter but a Java interpreter is not necessarily a JVM". Is that true? I mean is there a difference between a Java interpreter and JVM? 回答1: Yes, there is a difference. Java virtual machine: A software "execution engine" that safely and compatibly executes the byte codes in Java class files on a microprocessor (whether in a computer or in another electronic device). Java interpreter: A module that alternately decodes and executes

Deferred evaluation in python

回眸只為那壹抹淺笑 提交于 2019-12-03 06:54:48
I have heard of deferred evaluation in python (for example here ), is it just referring to how lambdas are evaluated by the interpreter only when they are used? Or is this the proper term for describing how, due to python's dynamic design, it will not catch many errors until runtime? Or am I missing something entirely? Dietrich's answer is a good one, but I just want to add that the simplest form of deferred evaluation is the if statement: if True: x = 5 else: x = y # huh? what is y? This code parses and runs correctly, although the else clause makes no sense - y is undefined. The else clause

Include jar file in Scala interpreter

别来无恙 提交于 2019-12-03 06:45:56
问题 Is it possible to include a jar file run running the Scala interpreter? My code is working when I compile from scalac: scalac script.scala -classpath *.jar But I would like to be able to include a jar file when running the interpreter. 回答1: According to scala executable help all options of scalac are allowed , so you can run scala -classpath some.jar , i've just tried and it looks like it works 回答2: In scala2.8,you can use scala>:jar JarName.jar to add a jar to the classpath. In Scala 2.8.1,

Is there a quick-starting Haskell interpreter suitable for scripting?

自作多情 提交于 2019-12-03 05:03:02
问题 Does anyone know of a quick-starting Haskell interpreter that would be suitable for use in writing shell scripts? Running 'hello world' using Hugs took 400ms on my old laptop and takes 300ms on my current Thinkpad X300. That's too slow for instantaneous response. Times with GHCi are similar. Functional languages don't have to be slow: both Objective Caml and Moscow ML run hello world in 1ms or less. Clarification : I am a heavy user of GHC and I know how to use GHCi. I know all about

Is it possible to use arrow keys in OCaml interpreter?

泄露秘密 提交于 2019-12-03 04:48:07
Everytime I use these keys in the interpreter I keep getting symbols like this appearing: [[D^[[C I'm using Linux Mint 12 in ZSH, however I'm getting the same result in Ubuntu with bash. Also, same thing in ssh. The stock OCaml toplevel doesn't have line editing built in. I use rlwrap : $ cat bin/ocaml #!/bin/sh exec rlwrap /usr/local/bin/ocaml "$@" Using the toplevel without something like this is quite painful, in my opinion! Other possibilities are to run the toplevel under emacs (a popular choice, I think), or to use utop . I haven't used utop, but it sounds cool. Another option is to use:

Are there any tutorials on building a simple interpreter using Alex + Happy?

 ̄綄美尐妖づ 提交于 2019-12-03 04:30:39
问题 I'm working on a school project where I have to build an interpreter for a simple language using Alex + Happy in Haskell. After looking through the documentation I understand most of it, but would like to see a full blown example on using the tools. 回答1: Not on building interpreters, but on building lexers and parsers, yes. See the example for a lexical analyzer in Alex, here, combined with an intro to Happy here. I found the haskell.x and haskell.y files distributed in the darcs repos for

How does code written in one language get called from another language

末鹿安然 提交于 2019-12-03 03:58:27
问题 This is a question that I've always wanted to know the answer, but never really asked. How does code written by one language, particularly an interpreted language, get called by code written by a compiled language. For example, say I'm writing a game in C++ and I outsource some of the AI behavior to be written in Scheme. How does the code written in Scheme get to a point that is usable by the compiled C++ code? How is it used by the C++ source code, and how is it used by the C++ compiled code

What is the difference between compilation and interpretation?

三世轮回 提交于 2019-12-03 03:56:40
问题 I just had a conversation with a colleague and where were talking about the V8 JavaScript engine. According to Wikipedia, V8 compiles JavaScript to native machine code [...] before executing it, instead of more traditional techniques such as interpreting bytecode or compiling the whole program to machine code and executing it from a filesystem. where (correct me if I'm wrong) " interpreting bytecode " is the way Java works, and " compiling the whole program " would apply for languages like C

How does an interpreter interpret the code?

大城市里の小女人 提交于 2019-12-03 03:43:38
问题 For simplicity imagine this scenario, we have a 2-bit computer, which has a pair of 2 bit registers called r1 and r2 and only works with immediate addressing. Lets say the bit sequence 00 means add to our cpu. Also 01 means move data to r1 and 10 means move data to r2. So there is an Assembly Language for this computer and a Assembler, where a sample code would be written like mov r1,1 mov r2,2 add r1,r2 Simply, when I assemble this code to native language and the file will be something like:

What are the tasks of the “reader” during Lisp interpretation?

孤人 提交于 2019-12-03 03:35:20
I'm wondering about the purpose, or perhaps more correctly, the tasks of the "reader" during interpretation/compilation of Lisp programs. From the pre-question-research I've just done, it seems to me that a reader (particular to Clojure in this case) can be thought of as a "syntactic preprocessor". It's main duties are the expansion of reader macros and primitive forms. So, two examples: 'cheese --> (quote cheese) {"a" 1 "b" 2} --> (array-map "a" 1 "b" 2) So the reader takes in the text of a program (consisting of S-Expressions) and then builds and returns an in-memory data-structure that can