So I've started work on my Clojure(lisp) in pypy interpreter again.
This time I've decided to take a very materialistic approach to the
design. As such my interpreter does not run off of bytecode, instead
it directly interprets the Clojure structures, truely treating data as
code. The idea is that every object in the system must have a
evauate() method, and optionally a invoke(args) method. These methods
are implemented as follows:

most objects return themselves when evalute() is run
def evaulates to itself, and when invoked, creates a named var that is
bound to the 2nd form. E.g. (def foo 1) creates a var named foo that
points to IntObj(1)
user defined functions create local bindings, and then invoke their contents
symbols search local bindings and global defs and then return the
result through evaluate()
lists evaluate all their contents, and then invoke the first item
passing it the rest of the list as arguments

With this simple approach, I've been able to implement many of the
clojure concepts with just a few lines of code. It really works well.

Here is my question. When I get a full program written, I'll have
hundreds of objects each with evaluate() and invoke() all will be
immutable, but there really isn't any sort of loop. We can implement
loops via recur:

(def (fn (x)
           (if (< x 100)
              (recur (inc x))
              x)))

But that's about the only loop in the interpreter.

So I know in "normal" jits you would "greenlight" the instruction
pointer of the byte code interpreter. Will PyPy not be happy with a
lack of an instruction pointer? If I flag every single class as
immutable, will it be able to still a decent jit? I guess, what I'm
asking is when do green and red variables need to be defined, is it
ever okay to not define them? Will the jit even work?

Thank you for your time,

Timothy

-- 
“One of the main causes of the fall of the Roman Empire was
that–lacking zero–they had no way to indicate successful termination
of their C programs.”
(Robert Firth)
_______________________________________________
pypy-dev mailing list
pypy-dev@python.org
http://mail.python.org/mailman/listinfo/pypy-dev

Reply via email to