Home > Archive > Tcl > December 2007 > Where is the expand {*} syntax in the man pages?
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Where is the expand {*} syntax in the man pages?
|
|
| Robert Hicks 2007-12-22, 7:16 pm |
| I can't seem to find it.
| |
|
|
| Robert Hicks 2007-12-22, 7:16 pm |
| On Dec 22, 5:45=A0pm, miguel <mso...@users.sf.net> wrote:
> Robert Hicks wrote:
>
> rule 5 in Tcl.n:http://www.tcl.tk/man/tcl8.5/TclCmd/Tcl.htm
Thanks! I wasn't expecting it there. : )
Robert
| |
| Tom Conner 2007-12-22, 7:16 pm |
|
"miguel" <msofer@users.sf.net> wrote in message
news:fkk42h$vgh$1@aioe.org...
> Robert Hicks wrote:
>
> rule 5 in Tcl.n: http://www.tcl.tk/man/tcl8.5/TclCmd/Tcl.htm
Rule 5:
"If a word starts with the string "{*}" followed by a non-whitespace
character, then the leading "{*}" is removed and the rest of the word is
parsed and substituted as any other word. After substitution, the word is
parsed again without substitutions, and its words are added to the command
being substituted. For instance, "cmd a {*}{b c} d {*}{e f}" is equivalent
to "cmd a b c d e f". "
Sorry for being dense, but I do not understand the example in the
documentation. Not having yet used {*}, or been exposed to its use, I do
not see what the advantage of {*} is in this example.
Why write "cmd a {*}{b c} d {*}{e f}" when it is easier to type "cmd a b c d
e f"?
| |
| Donal K. Fellows 2007-12-22, 7:16 pm |
| Tom Conner wrote:
> Why write "cmd a {*}{b c} d {*}{e f}" when it is easier to type "cmd a b c d
> e f"?
With literals? It's just syntactic completeness really (though of some
use if you want to put the words in the expanded value on multiple
lines I suppose). But the interesting cases are these:
cmd a {*}$bc d {*}[e f]
That is, the lists can be not just literals but also come from
variables or commands. That *is* useful.
Donal.
| |
| miguel 2007-12-22, 7:16 pm |
| Tom Conner wrote:
> "miguel" <msofer@users.sf.net> wrote in message
> news:fkk42h$vgh$1@aioe.org...
>
> Rule 5:
>
> "If a word starts with the string "{*}" followed by a non-whitespace
> character, then the leading "{*}" is removed and the rest of the word is
> parsed and substituted as any other word. After substitution, the word is
> parsed again without substitutions, and its words are added to the command
> being substituted. For instance, "cmd a {*}{b c} d {*}{e f}" is equivalent
> to "cmd a b c d e f". "
>
> Sorry for being dense, but I do not understand the example in the
> documentation. Not having yet used {*}, or been exposed to its use, I do
> not see what the advantage of {*} is in this example.
>
> Why write "cmd a {*}{b c} d {*}{e f}" when it is easier to type "cmd a b c d
> e f"?
For example in
unset {*}$varList
Previously you'd have needed
eval unset $varList
or else
foreach var $varList {unset $var}
| |
| Alan Anderson 2007-12-23, 7:21 pm |
| Robert Hicks <sigzero@gmail.com> wrote:
> On Dec 22, 5:45_pm, miguel <mso...@users.sf.net> wrote:
>
> Thanks! I wasn't expecting it there. : )
You did ask the question correctly, calling it "syntax". Getting the
question right is often as good as already knowing the answer. Even
with the new twelfth rule, Tcl's syntax is simple enough that it is
described completely in the "main" Tcl man page.
|
|
|
|
|