[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Edit and Continue: Part 2
- From: "Max McGuire" <max@...>
- Date: Wed, 7 Nov 2007 18:51:53 -0800
Edit and continue is something I've experimented with a bit for Decoda. I had pretty good success (at least to a proof of concept stage) by rewriting the Lua source code at run-time to allow individual lines to be patched.
For a basic statement it's something like this:
if (patch_N) then patch_N() else <original code from line N>
To replace line N, you just create a new function with the code and assign it to patch_N. Of course there is some complexity when dealing with local variables, upvalues, etc. and constructions like ifs and loops, but I think the Lua API provides the necessary hooks and with enough effort it can be done. The additional code will also affect the run-time performance, but in my experience this isn't really an issue for most applications.
We'll probably include something like this in a future version of Decoda. Having direct support in Lua for edit and continue would certainly be nice, but I assume this is not a simple thing to add into the interpreter.
On 11/6/07, Peter Sommerfeld <email@example.com
Don Hopkins schrieb:
> If we did it again from scratch, I would choose Lua as the underlying
> scripting language, and write a custom special purpose language and
> visual programming tool on top of that.
> I don't think that it would be necessary to change the Lua language
> itself to support edit and continue, just write the visual language
> interpreter in Lua and integrate it with the application code in the
> right way.
I think that is the right way to do things like this. Lua ist best
suited to develop higher level domain specific languages and too much
syntactic sugar adds unneccesary burden to it. IMHO Luas role for
scripting is comparable to that of C for programming. Hence I like it as
it is: small, fast, minimalistic, powerfull and easily entendable and
But I am quite sure its authors will resist all temptations to go into
the direction of higher level scripting languages.
Unknown Worlds Entertainment