Questions tagged [interpreter]

An interpreter is a program that executes, i.e. performs, instructions written in a programming language. The tag [interpreter] should be applied to questions concerning the programming of interpreters or for questions about the detailed inner workings of interpreters. Use [interpreter-pattern] (possibly with this tag) for questions about the Gang of Four design pattern.

An interpreter is a program that executes, i.e. performs, instructions written in a programming language.

An interpreter may be a program that either

  1. executes the source code directly
  2. translates source code into some efficient intermediate representation (code) and immediately executes this
  3. explicitly executes stored precompiled code1 made by a compiler which is part of the interpreter system

From wikipedia

2265 questions
29
votes
10 answers

Can a compiled language be homoiconic?

By definition the word homoiconic means: Same representation of code and data In LISP this means that you could have a quoted list and evaluate it, so (car list) would be the function and (cdr list) the arguments. This can either happen at…
user141335
28
votes
1 answer

How come when I press the Up or Down Arrow keys in the Python interpreter I get ^[[A or ^[[B instead of history?

Possible Duplicate: Python shell: Arrow keys do not work on remote machine I have no idea why history won't work in the Python 2.7.2 interpreter. I get strange character groups for each of the arrow keys. This doesn't happen in Terminal. BTW I am…
user883807
28
votes
4 answers

What does PyPy have to offer over CPython, Jython, and IronPython?

From what I have seen and read on blogs, PyPy is a very ambitious project. What are some advantages it will bring to the table over its siblings (CPython, Jython, and IronPython)? Is it speed, cross-platform compatibility (including mobile…
Jason Christa
  • 12,150
  • 14
  • 58
  • 85
28
votes
6 answers

Haskell interpreter on Android?

Is there a Haskell interpreter (with standard libraries) that can be installed on Android? So that someone with an Android device can do some Haskell exercises on an Android device: write and run some example code in Haskell.
imz -- Ivan Zakharyaschev
  • 4,921
  • 6
  • 53
  • 104
28
votes
4 answers

Does python reuse repeated calculation results?

If I have an expression that I wish to evaluate in Python, such as the expression for r in the code snippet below, will the Python interpreter be smart and reuse the subresult x+y+z, or just evaluate it twice? I'd also be interested to know if the…
user189076
  • 439
  • 3
  • 7
28
votes
1 answer

"Strictly positive" in Agda

I'm trying to encode some denotational semantics into Agda based on a program I wrote in Haskell. data Value = FunVal (Value -> Value) | PriVal Int | ConVal Id [Value] | Error String In Agda, the direct translation…
Jason Reich
  • 1,168
  • 9
  • 15
27
votes
7 answers

Include jar file in Scala interpreter

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.
BefittingTheorem
  • 10,459
  • 15
  • 69
  • 96
27
votes
3 answers

How to write a linker

I have written a compiler for C that outputs byte code. The reason for this was to be able to write applications for an embedded platform that runs on multiple platforms. I have the compiler and the assembler. I need to write a linker, and am…
26
votes
6 answers

Does a browser truly read JavaScript line by line OR does it make multiple passes?

I understand that JavaScript is interpreted and not compiled. No problem there. However, I keep reading here that JavaScript is executed "on the fly" and that lines are read one at a time. This idea is confusing me quite a bit when it comes to…
user1971506
  • 2,267
  • 4
  • 19
  • 19
25
votes
9 answers

Detecting infinite loop in brainfuck program

I have written a simple brainfuck interpreter in MATLAB script language. It is fed random bf programs to execute (as part of a genetic algorithm project). The problem I face is, the program turns out to have an infinite loop in a sizeable number of…
Sundar R
  • 13,776
  • 6
  • 49
  • 76
25
votes
2 answers

In the Python interpreter, how do you return a value without single quotes around it?

In the Python interpreter, how do you return a value without single quotes around it? Example: >>> def function(x): ... return x ... >>> function("hi") 'hi' I expect it to return hi instead of 'hi'
user176073
25
votes
2 answers

Is it possible to use arrow keys in OCaml interpreter?

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.
Pacane
  • 20,273
  • 18
  • 60
  • 97
25
votes
3 answers

how to repeat last command in OCaml interpreter shell

I've been trying out OCaml. Sometimes its quicker just to test out some code using the interpreter shell but, it doesn't bring up the last command when I press the 'up' key. Its a pain when I miss type something or wish to see what a little…
neildaemond
  • 656
  • 1
  • 8
  • 17
24
votes
3 answers

How to fix column calculation in Python readline if using color prompt

I use standard tips for customizing interactive Python session: $ cat ~/.bashrc export PYTHONSTARTUP=~/.pystartup $ cat ~/.pystartup import os import sys import atexit import readline import rlcompleter historyPath =…
gavenkoa
  • 45,285
  • 19
  • 251
  • 303
24
votes
4 answers

How does an interpreter interpret the code?

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…
Koray Tugay
  • 22,894
  • 45
  • 188
  • 319