In article <uq2gmt$1v2vf$
1...@dont-email.me>,
Harald Oehlmann <
wort...@yahoo.com> wrote:
...
>> Why?
>>
>
>Try:
>
>set foo [regexp -inline {[0-9]+} [time {sleep 5}]]
>
>or
>
>set foo [regexp -inline \[0-9\]+ [time {sleep 5}]]
>
>You close the opening "[" with the RE. This does not play any role, if
>you don't open a "[".
I'm actually more interested in "why", than in alternatives.
(But note: Yes, both of your alternatives do work)
So, maybe an insight as to why?
The point is why does it work OK when you just print the result, but fails
when you wrap it inside a "set" to capture the result?
I suppose it is an instance of a common/general problem with TCL - that it
encourages "slop" - coding that isn't correct, but usually works. I've
gotten into the habit - with all kinds of Unix "regular expression"-using
programs - that you only have to escape the first [ (and not the closing ])
because if the first one is escaped, then the second one is sort of
'auto-escaped'. You'd be surprised how often this works OK (even though, I
suppose, it shouldn't).
This kind of "slop" is why some people say disparaging things about TCL as
a programming language. Well, one of the common reasons; there are others.
I'm not really a TCL programmer (I just fake it), but I've been programming
Expect for decades now.
--
The randomly chosen signature file that would have appeared here is more than 4
lines long. As such, it violates one or more Usenet RFCs. In order to remain
in compliance with said RFCs, the actual sig can be found at the following URL:
http://user.xmission.com/~gazelle/Sigs/Rorschach