On 11/20/2012 10:00 AM, Marco Pallante wrote:
In this case, Tcl already does what you want. It's called
auto_load.
I remember I've seen it before, but didn't come to mind because I
never used it. I'll give it a look, because seems to fit well.
All that being said, it may be a better idea to be explicit. [...]
I generally agree, but web developers I personally know are very
lazy. Again, I'm exploring a few options now, I haven't really
decided how the framework will be.
the autoloader is so easy that everyone used to benefit from it almost
unknowingly. But it's going and we now have to find our own best
strategies and practices to address the problem. Usually it takes a few
attempts before the best approach emerges, so we should mourn the
loss and start to think in terms of what's lying ahead. I think that
regarding dynamical code loading at the abstract level all our problems
look alike. Do you feel like you want to explore this problem and
develop something to become a component of our Tcl stuff?
3. Initialize your framework in the global namespace one time
using the package mechanism, then you don't have to incur that
cost with each request. ESPECIALLY in production code. I built a
debug variable in which says that I'm in a "dev" instance of the
framework, and in dev mode the entire framework is reloaded with
each request. This is for me when I'm developing the framework
and other bits. I want to reload each time to make sure my changes
are in.
I'm following a similar path, but with a big difference: I load code
into the global namespace only if the SeparateVirtualInterps is
true (and I always put data into ::request).
The reason is simple: if, let's suppose, someone starts a hosting
company offering Rivet access, then unless SeparateVirtualInterps is
true the global namespace becomes shared among different virtual
hosts belonging to different users (as soon as requests go to the
same Apache child, I know). Then, I *should not* put code into the
global namespace because it could interfere with other users code.
I guess SeparateVirtualInterps was introduced exactly for this purpose.
I don't know of any hosting company offering Rivet to their customers
though :-(
-- Massimo
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]