THT /
Design
Search:  


THT Design

By default, THT creates a sub-interp per page within which Tcl gets evaluated. For simple CGI mode, this is not all that important. However, when running any other mode (eg. FastCGI), this is critical. It means that built-ins and libraries do not need to be recompiled for each request. Moreover interp deletion provides an efficient and effective cleanup between requests.

A separate interp make for a clear isolation between built-ins and user code. It can also be used to limit access to sensitive commands and/or modify their behavior. This approach also leaves open the future use of threads. THT also provides a -safe option for making the sub-interp use Safe-Tcl. Going the other way, a -subinterp option can even eval pages in the toplevel interp. Any way you slice it, interps provide great flexibility.

Access to built-in commands in THT is managed through interp aliases. The built-in procs themselves reside in the toplevel interp, and thus do not require a re-bytecompiling for each page. The only limits this places on built-in code is with upvar and uplevel. However, these are easily worked around, and in principle large libraries shouldn't be difficult to develop as built-ins. This should allow a relatively small resource footprint per page-render.

© 2008 Peter MacDonald

Page last modified on January 14, 2010, at 07:00 PM