Robin Houston wrote:
> On Tue, Jul 03, 2001 at 05:27:02PM +0100, David Cantrell wrote:
> > So, as someone who probably knows tcl better than I do - is 
> > it a tclism or a SSism that you have to use a different
> > number of [[[[ depending on how deeply nested your code is?
> 
> You mean \\\\[ right?
> 
> It's an SSism, and an especially egregrious one.

I agree. Another SSism is their tendency to eval strings if you use the
CAPITAL_LETTER commands. Example: I had some code which basically wanted to
do

    s/([^goodchars])/'&#' . ord($1) . ';'/eg;

, but of course Tcl's regsub command doesn't have an /e option, so what I
actually do is

  regsub -all  {\[^goodchars\]} $sTxt {\\&#\[scan "&" %c nWert; set
nWert\];} sTxt

, that is, something with a [command] in it, which I then run through subst
(which is a bit like eval; it replaces the sequence [stuff] in strings with
the output of the command stuff, and a couple of other things). Then,
someone else, who used SET all over the place while I use set, used a
similar recipe and found that he didn't need the subst; apparently, the SET
did it for him. Ick -- you never know what's going to be interpolated when,
and "unknown command 'foo'" is the order of the day if you get square
brackets in strings in the wrong places. Ugly ugly.

Yes, SS does ensure that an understanding of Tcl's interpolation and
backslash rules is not enough. (Add to that the fact that you *usually* need
two, four, or eight backslashes, but if you want to escape square brackets,
you need three or five instead, i.e. (two or four) + 1.)

Leading to the always popular "guess how many backslashes you'll need in
this code", and as you said, that number can change if you re-nest things. I
added an IF { } around some code and all my "foo\\n" strings had to change
to "foo\\\\n" -- as if "\\n" for a newline weren't ridiculous enough (but if
you write "\n", then SS eats the \ and Tcl only sees "n" and outputs that).

> Of course they can't fix it, because it'll break everybody's
> old code :/
> 
> Actually I think newer releases have a
> please-dont-make-me-count-the-backslashes option, but it's off by
> default.

I wonder how it's supposed to work.

Cheers,
Philip
-- 
Philip Newton <[EMAIL PROTECTED]>
All opinions are my own, not my employer's.
If you're not part of the solution, you're part of the precipitate.

Reply via email to