Forum OpenACS Q&A: Upvar & uplevel are your enemies.... (tcl losage and ACS design)

Which version of the ACS?

I may be all off about this, but I have seen this before under OpenACS 3.2.5, esp. in an environment where I had transplanted some Classec ACS 3.4.10 code into the OpenACS libraries.

If I recall what I found it is that a lot of the ACS security code was written in much too clever a fashion, relying on an uplevel to set various "global" parameters in your tcl interp so that you didn't have to set them yourself (say via (array set (fn (return (list ...))))).

The problem is that the aD code that did this created a dependency that your call level at the time of the uplevel be a precise number of levels down (or up).  (Since the call to uplevel is something like, uplevel *level number*).  There are places where that dependency is broken, and when it is, and the global variables have not been set, I have seen routines that rely on those parameters to exist die, even within a catch.

Upvar and uplevel -- fooey -- talk about dangerous and stupid ways to break any piece of modularity in your code.  Whatever was wrong with (defmacro ...) Mr. Ousterhout?