Purpose: discuss what all is known about Tcl variable names - what are the limits, tricks, and tips? ---- [LV]: I've seen people show examples of Tcl variable names from 0 characters long to quite long (more than 30 I believe). The names can contain spaces and many other special characters. I would, myself, avoid the use of metacharacters such as [[ ]] , ( ) $ : { } and probably a few others, just to save myself the quoting nightmare that one might encounter. I also believe that some extensions impose additional 'restrictions' - for instance, I believe that Tk generally expects widget names to begin with a period and not to use an upper case alpha as the first character. [RS]: As far as I'm aware, a variable name may be any string, from the empty string up. (Well, sequences of colons (two or more :) have special meaning, so they cannot be arbitrarily thrown in). The $ parser restricts variable names to [[A-Za-z0-9_]], so it's wise to stay in that range (otherwise you might have to brace (which prevents Unicode expansion... or use [[[set] \u20AC]] if you have a variable name with the Euro sign. [Rolf Ade]: I can do 'set � foo; puts $�' (this � is adiaresis, if you only see a strange char). What do you mean with "The $ parser restricts variable names to [[A-Za-z0-9_]]? [RS]: I've heard there was a bug report so "national" letters would also be allowed by the $ parser... so it seems this has been fixed. Which version? [RS]: In 8.2.3, "�" is not taken by the $ parser. [Rolf Ade]:8.3.2 [KBK]: The bug is still open as of 17 January 2002: [https://sourceforge.net/tracker/?func=detail&aid=408568&group_id=10894&atid=110894]. Once it's fixed, there oughtn't to be anything wrong with a variable substitution like $h�t�rog�n�it�. (Heterogeneity of the languages accepted would be a good thing...) (Just checked: it depends on the native isalnum() call, but certainly you can't name a variable \u03b3 and accept the $-parser to take it, even when eval'ing a Unicode string.) [TV] The delimiters of the variable names are important, I in [bwise] use variables with dot notation, which works, but for instance when printing a var, evaluating a string with the name in it requires quoting/list-ing. In fact, the dot is taken as name seperator anyway, so braces must be used to access the variable: set group.element 3.14 puts ${group.element} because this is ''wrong'': puts $group.element puts $group\.element puts "$group.element" i.e. that doesn't work. I didn't check wether the tcl language spec explicitly allows dots in variable names, or wether such case is mentioned at all, but I've got quite old bwise code which I don't like to go over again and change all dots in. Strictly I guess they aren't needed, but I call blocks by a name, and then make block variables with name.vars notation, so one could (later) use info vars groupname.* which is cool enough. I don't like typing two semicolons :: on a row, but then again, I guess anything to use as explicit seperator can work fine. It seems that the constructs I use in [bwise] work in general, have a look at them to at least have working examples of using these type of variable names in complex constructs, also for indirect referencing, and containing tcl code which can be eval-ed. No beauty queen contest of code smoothness, but compact, efficient (as far as that goes in runtime) and for me overseeable and un-tricked stuff.