Re: Variable ontology (was: Q: Pointers in TCl) _________________________________________________________________ From fellowsd@cs.man.ac.uk (Donal K. Fellows) Organization Dept of Computer Science, University of Manchester, U.K. Date 3 Apr 1998 10:15:33 GMT Newsgroups comp.lang.tcl Message-ID <6g2cs5$fv5$1@m1.cs.man.ac.uk> References 1 2 3 4 _________________________________________________________________ In article <6fvqfe$7q0$1@Starbase.NeoSoft.COM>, Cameron Laird wrote: > 2. Who uses subst? I just grilled Donal Fellows about > this, and the strongest proposition to which we > could jointly agree was that it's a lot like LISP's > macros. > > This is my position: every time I've used a subst, > I've ended up being happier with a different formu- > lation that didn't (confession: I'm eval-intoxicated). > I'm curious to learn whether anyone has a real > compelling instance of subst-ing. The two domains > that seem likely to me are some kind of CGI template > expansion, and processing of a configuration-speci- > fication-that-is-written-as-an-executable-script. I typically don't use [subst] either, but there are a few times when not having it available blows up the complexity of the code by a few factors, making it harder to write, understand, maintain and document. In those rare cases, [subst] is invaluable. The case in point thart illustrates this: I have a chunk of code that does menu management (it collects the whole lot together in one place, including proper handling of accelerators, tooltips, the lot.) and this allows me to compress pages of complex and non-obvious code into (effectively) a structure that describes it all in one place. This gives a massive gain. Unfortunately, I want to apply this to several toplevel windows, and the commands attached to the menu entries need to be specialised according to which particular window they were located in. Doing this piecemeal is out of the question, and an eval would do far too much (I don't really trust eval - it doesn't feel like a safe construct to me.) A quick [subst -noback -novar] did the trick wonderfully. It even highlights nicely in my copy of emacs... :^) Donal. -- Donal K. Fellows http://r8h.cs.man.ac.uk:8000/ fellowsd@cs.man.ac.uk Department of Computer Science, University of Manchester, U.K. +44-161-275-6137 -- Never underestimate the power of the penguin...