Re: A tiny bit of code by RS puzzles me

From: Andreas Leitgeb (avl_at_gamma.logic.tuwien.ac.at)
Date: 11/29/04


Date: 29 Nov 2004 15:49:52 GMT

Donal K. Fellows <donal.k.fellows@manchester.ac.uk> wrote:
> Andreas Leitgeb wrote:
>> Helmut Giese <hgiese@ratiosoft.com> wrote:
>>>[...quote from one of RS's wonderful pages...]
>> While it is surely a nice hack, it still *is* a hack
>> with severe limitations:
>> PS: So, kids, don't do this at home :-/

> Well, actually you should rewrite it to be more like this:
> proc integer args {
> foreach arg $args {
> set var [list $arg]
> uplevel #0 "trace var $var w {incr $var 0 ;#}"
> }
> }
Ok, this solves issue#1 raised (that was: badly-behaving varnames)
but breaks "integer" completely for local variables.

> Making it automatically handle the cases where it is in a non-root
> namespace (without fully-specified names) is left as an exercise.

This is the one that will quite surely thwart the elegance.

With closures, it would be still elegantly solveable, though
closures are not (yet?) part of Tcl.