Cecil Westerhof <
Ce...@decebal.nl> wrote:
> Cecil Westerhof <
Ce...@decebal.nl> writes:
>
>>> Also, the OP should take note of the fact that in many instances
>>> where he believes he wants pointers, an array will provide the same
>>> solution without the extra trickery.
>>>
>>> I.e., for this example: set index(dummy) "Some information"
>>>
>>> And if he wants to pass the "array" in/out of procs without using
>>> upvar, then use a "dict" instead.
>>
>> That is a good tip. Changed the code to work with a dict. Now I have
>> to wait until I can test it.
>
> I simulated something and that worked. So probably it is OK. Waiting
> till a real situation pops up.
Variable indirection is useful, but the low complexity cases are where
it is best used.
I.e., validations are a good spot. Say you've got four input fields,
with appropriate linked variable names, and you want to make sure none
are over 80 characters (this is all made up):
set errors [list]
foreach var {name, street_1, street_2, city} {
if {[string length [set $var]] > 80} {
lappend errors $var
}
}
if {[llength $errors] > 0} {
# handle the validation issues here as appropriate
}
But trying to simulate C pointers rapidly becomes a nightmare of
keeping track of what is happing where for what reason and from where.