So, do you want RESET?

Carl Sassenrath, CTO
REBOL Technologies
10-Oct-2010 0:35 GMT

Article #0340
Main page || Index || Prior Article [0339] || Next Article [0341] || 18 Comments || Send feedback

Long ago, in what seems like a galaxy far far away, REBOL had a reset function... it was a sort of warm-reboot that restarted REBOL without requiring the exe to be reloaded. This function was added because Jeff Kreis created an Apache web server module for REBOL, and it needed to run "fresh" for each new server request. Quite handy.

Although I'm not considering adding such a function this week (there are higher priorities), I want you to think about it a little... and some of you guru's will recognize that such a function is actually on the road to multi-tasked REBOL environments.

To add a function like reset we need to define the baseline to which the system resets. Then, everything below the baseline must be protected (immutable). Of course, some values, like the system object can be mutable and just get rebuilt as part of the reset.

One method would be to use a checkpoint function that would clone a copy of the lib context and protect the entire base. The checkpoint allows you to import various modules and get things setup for your baseline, then mark that for rolling back to later.

When the reset occurs, the user context would get cleared and the lib context would be reset to the check-pointed values. That way you have a fresh environment setup exactly how you want it.

Of course, all data and functions below the checkpoint would need to be protected (made immutable), but the entire algorithm could probably be implemented in about a dozen lines of gurumezz code. In addition, we'd want the mutable parts of the system object to be rebuilt, but that's not difficult.

So... the hard part is designing the base to be immutable. That is, functions and objects must not store state.

But, wait... now you found me out! That's the same requirement needed for R3's lightweight multitasking model, isn't it? In essence, if we do one, we get the other (mostly) for free.

Ok, why do I mention any of this? Because to move to beta, this is one big old check-box we need to mark off.

The time is near. Keep it simple and clear. (Sorry... the Cabernet fermentation fumes must be getting to my head.)


Updated 24-Jun-2024 - Edit - Copyright REBOL Technologies -