Re: [livecode] Hello (& chaos)

From: Rob Myers <robmyers_at_mac.com>
Date: Fri, 10 Sep 2004 10:36:22 +0100

 Hello to the list

On Friday, September 10, 2004, at 10:23AM, Danny Ayers <danny.ayers_at_gmail.com> wrote:

>Not as it stands, nope - Java probably isn't a good language for that
>kind of change, though changing the value of the feedback constant
>would have a marked (and fairly unpredictable) effect.

There's a number of ways of doing it. Java has a number of interpreters for other languages available, so the changeable code could be written in (say) JavaScript. But that kinda breaks the model.

Writing bytecodes by hand is a no-go. :-)

So the best way would be to use Java's dynamic class loading and reflection functionality:
1. Have a text window with the running algorithm code in.
2. When the user changes the algorithm, get the text and wrap it in some boilerplate (a class with a single well-known method).
3. Compile it either by having linked the program to JavaC or by calling Runtime.exec("javac name-of-file-you-saved-the-text-in.java"), and check for errors.
4. Load the compiled class, get the method, and swap it for the one currently being called.

Sounds insane but it's doable. Modern Lisp systems compile code typed at the toplevel before running it, so this has some precedent (although the Lisp systems have the compiler built in and optimised for this).

I'm not suggesting you should actually do this, though. :-)

- Rob.
Received on Fri Sep 10 2004 - 09:37:28 BST

This archive was generated by hypermail 2.4.0 : Sun Aug 20 2023 - 16:02:24 BST