Original post by Kylotan
TCL''s namespaces look more like a hack that gets around the problem rather than a clean solution. (Relative to the problem, that is - I''m sure they are an elegant solution to other issues.) Does it support restarting a script half-way through?
Admittedly, this solution is probably beyond the original intention of namespaces. The language itself doesn''t support restarting scripts, but it can be simulated through an extension. You''d have to pass the code within my theoretical When command back to the interpreter extension (the When command''s code) as a string argument, store the string in the engine''s queue, and pass it back to the interpreter when the condition is met, executing it in the script''s original namespace so previously declared variables don''t get lost. When the script is terminated, we can clear the namespace. This would solve the problems we discussed about maintaining scope and passing control back to the engine itself.
Doesn''t sound very elegant, does it? It may not be; I haven''t actually tried to implement it. Also, it negates the possibility of precompiling scripts, since the engine is being forced to treat code as data. I''m at a loss for a better solution, though.
I won''t beat this dead horse any longer, but if you have any other thoughts, I''d love to hear them. It''s been an interesting discussion.