View previous topic :: View next topic |
Author |
Message |
csauls
Joined: 27 Mar 2004 Posts: 278
|
Posted: Tue Sep 11, 2007 8:18 pm Post subject: Unloading modules. |
|
|
Is there, or could there be, any way to un-load, or even re-load, a MiniD module? This would be nice for long-lifetime programs that want to allow "realtime" editing of user code. _________________ Chris Nicholson-Sauls |
|
Back to top |
|
|
JarrettBillingsley
Joined: 20 Jun 2006 Posts: 457 Location: Pennsylvania!
|
Posted: Wed Sep 12, 2007 6:47 am Post subject: |
|
|
I hadn't thought of that. Something that's a bit tricky to deal with though, is: say you have a.b and a.b.c. (Modules == packages, so this is legal) If you unload a.b, there's no real way to keep a.b.c loaded as well, since you don't really know what symbols belong to a.b and which belong to a.b.c. I suppose from an unloading point of view, unloading a.b also unloading a.b.c makes sense, but then you'd have to reload both of them..
Now, reloading. That might allow for just about the same level of utility but without the trickiness of having to mess with subordinate modules. Although there's also the risk of having the module namespace be "polluted" with old symbols from previous incarnations of the module that were removed in a later version. Hm.
In either case, though, there'd have to be a search for any loaded subordinate modules, since looping through the symbol table looking for namespaces isn't sufficient (since you can define your own namespaces and all). Because of the search, the mechanism will be able to flag certain symbols as "don't remove me", and then remove everything else from the symbol table.
I could see this working.
The only other issue I can think of right now, and I don't think there's much of a solution to this, is if some other piece of code caches a reference to one of this module's functions in some way. So if this were a moth module, and it had some crazy transcendental function that someone else used as an upvalue for a nested function, i.e. "function makeSequence(f) { local i = 0; return function() { i++; return f(i); }; } local foo = makeSequence(mymath.tanhxyzx);". Now that closure references a function from the old module. If that function is subsequently replaced, this closure will still reference the old function, but code which explicitly names the function will use the new. (This problem isn't really unique to this feature, but I'd imagine it'd come up a lot more often with this than in other cases.) |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|