Forum OpenACS Development: Re: uplevel with passed variables

Posted by Benjamin Bytheway on
Why cannot this be done by setting and returning an array of the attributes? The method you've currently described is really an abuse of upvar/uplevel, and should be avoided.

It creates the situation where procs are making assumptions about the callers variable space.  Relying on procs to setup variables for you creates code that is difficult to maintain.  Variables are used that pop up out of nowhere, with no indication who actually set them in the first place.

Upvar and Uplevel have been abused in this project, mainly, I think, to work around shortcomings of tcl that have since been improved/corrected in 8.x.

For proper use of Upvar and Uplevel, see Rob Mayoff's guidelines:

Posted by Andrew Piskorski on
Incidentally, there is never any good reason to abuse upvar, as using it correctly is exceedingly easy, and I would hope, usually obvious. Using uplevel well is perhaps less straightforward and thus, ugly usage more forgivable.

Rob's guidelines above are very good, thanks for that reminder.