Extending the tcl interpreter is dead simple as there are hundreds of examples of how to do it in the aolserver source code, though you have to be careful that the underlying library that you're extending is thread-safe. If the library is not thread-safe, there are work-arounds that have the unfortunate side-effect of limiting performance.