Re: new problem in "switch"



On Wed, 11 Oct 2006, Robert Heller wrote:

At Wed, 11 Oct 2006 07:55:30 +0300 Kaitzschu <kaitzschu@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx> wrote:

switch x {
a {puts hello}
# {well this comment causes no trouble}
b {puts hi}
}
and get away with a little bit easier (but, naturally, less pleasant to the eye) solution (hint: check $cas).

No, this won't work either *as a comment*. This will just match the '#' case and execute the command 'well', with the argument list {this comment causes no trouble}.

Nope, not *as a comment*, since you *can't* have comments as this. Thus you have to parse the comments yourself. That is what my hint meant, if one wants to do what parser doesn't do then one has to do some parsing. Surely the easiest way here would be do that in [switch] proc,
if {$case eq {#}} {continue}

Naturally, # is very much arbitrary string in this case (and should be selected in such way there is no use for that), but this particular one would also look like a real comment.

--
-Kaitzschu
s="TCL ";while true;do echo -en "\r$s";s=${s:1:${#s}}${s:0:1};sleep .1;done
.