Re: Reset an interpreter instance
Matthias Radestock <[email protected]>
| Newsgroups | gmane.comp.java.sisc.user |
|---|---|
| Message-ID | <[email protected]> |
"Marco Bakera" <[email protected]> writes: > The "problem" is that I get user input to be evaluated by a previously > with some of my own definitions inited interpreter instance. Although > it's possible to create such a new interpreter each run and init it > with some of my definition this process takes some time I wanted to > get rid off. > > Perhaps I can speed up the process by putting my own definitions into > the heapfile. But I didn't tried that. I just wanted to know whether > there may be a shorter way for me by simply calling (reset) or > something like this. ;) One way to accomplish what you want is to compile all your code, which will make it fast to load, and then load it into a fresh environment in which you subsequently evaluate the user code. Something along the lines of (define e (sisc-initial-environment)) (eval '(load "your-code.scc") e) (eval user-code e) The environment you get from sisc-initial-environment is a child environment of the environment which contains all the bindings from the heap. Because it is a child env, any additions or modifications will not affect the parent environment. I think this is the best you can to do for the time being, without hacking into the sisc internals via s2j. I reckon there should be a better way though: One should be able to create child environments of *any* environment. Then you could write something like: (define e (sisc-initial-environment)) (eval '(load "your-code.scc") e) (define ee (child-environment e)) (eval user-code ee) and only repeat the last two steps in order to evaluate code in an environment that contains all heap bindings plus your own code. Please raise a feature request for this. Matthias ------------------------------------------------------- This SF.Net email is sponsored by xPML, a groundbreaking scripting language that extends applications into web and mobile media. Attend the live webcast and join the prime developer group breaking into this new coding territory! http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642