Re: read/write on parse tree program representation (RE: Languages and AI)

From: Eliezer S. Yudkowsky (
Date: Fri Jul 20 2001 - 16:52:42 MDT

Ben Houston wrote:
> You're not going to like my response.
> >Really? Fine. I want to be able to access the PARSED source code, not
> >the plaintext, from inside the program. Furthermore, I want to be able to
> >alter the parsed source code, represented in a natural way (i.e., an
> >expression is a tree and not a series of machine instructions). I want to
> >be able to annotate any element in this tree, whether a branch or a leaf,
> >with complex data structures of my own devising, including new data types
> >of my own devising, without destroying the integrity of the existing data
> >or preventing the code from executing. Any existing languages got that
> >feature, which is simply first on the list?
> Basically you would need into integrate a Java decompiler and a Java
> compiler into your program so that it can decompile and compile you programs
> at run-time but that shouldn't be too hard - there are a lot of open source
> Java decompilers and compilers. Without any changes to the Java compiler
> you might lose the names of the non-exposed variables and functions but I
> think that if you have control of the Java compiler you can keep them.
> You'll probably want to turn off all the optimizations that the compiler can
> do in order that the decompiled code looks like the original code.

Guess what, Ben, I once wrote a piece of code that did that, too, and
NIINF. "No, It Is Not Flare." I do not want to have to compile, much
less decompile and recompile, a .class file every time I want to make a
single change. The idea is absurd. If I was going to create that kind of
hack, I would use regular expressions and write my own Perl parser in
Perl. Better yet, I would use Common LISP. The only reason I wrote a
piece of code that compiled and decompiled class files was to try and
create a Java interpreter in Java, back when Java first came out, before
Java had a java.lang.reflect feature.

> How to implement this programmatically? I would suggest a "function lock"
> or an "object lock" mechanisms kind to how one locks memory in a shared
> memory system (although you could get the parse tree without locking it,
> locking is only required for modifying it). During the time it is locked if
> one tries to execute it an exception will be thrown. Soon as you unlock a
> function or object it will be re-compiled. This would require a little
> modification of the VM but not a huge amount.

And now we're supposed to be modifying the VM too?!

-- -- -- -- --
Eliezer S. Yudkowsky
Research Fellow, Singularity Institute for Artificial Intelligence

This archive was generated by hypermail 2.1.5 : Wed Jul 17 2013 - 04:00:36 MDT