Re: Quoted substitution
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.tcl archive

Re: Quoted substitution

From: Glenn Jackman <xx087@freenet.carleton.ca>
Date: Sat Dec 17 2005 - 17:57:56 CET

At 2005-12-17 07:47AM, Ian Bell <ruffrecords@yahoo.com> wrote:
> Incidentally, man Tcl says:
>
> If a word contains a dollar-sign (``$'') then Tcl performs variable
> substitution: the dollar-sign and the following characters are replaced in
> the word by the value of a variable.
>
> I think this is not strictly correct and also explains why $$a works as it
> does. I suspect it should read 'the dollar sign and the characters
> following up to the next dollar sign in the word or the end of the word are
> replaced....

I think you're missing this sentence from the Tcl man page:
    There may be any number of variable substitutions in a single word.

Looking at '$$a', at the first dollar sign Tcl doesn't find an open
brace or a number, letter, underscore or colon as the next character.
So the parser moves on to the next character, the second dollar sign
where it finds a valid variable substitution.

-- 
Glenn Jackman
Ulterior Designer
Received on Fri Dec 23 19:01:54 2005