On Thu, 13 Jan 2000, Ken Bowen wrote:
> On Wed, 12 Jan 2000, Larry W. Virden wrote:
>
> > eval is specifically intended to do the conversion of a list into seperate
> > arguments...
>
> I must be living on a different wavelength. From the help file:
>
> "Eval takes one or more arguments, which together comprise a Tcl script
> containing one or more commands. Eval concatenates all its arguments in
> the same fashion as the concat command, passes the concatenated string to
> the Tcl interpreter recursively, and returns the result of that evaluation
> (or any error generated by it)."
>
> Probably I'm misunderstanding what's being said. Below, we get back from
> eval one single list whose length is 4:
>
> % llength [eval list a b c d]
> 4
I think you're correct. IE, you're living on a differnt wavelength! ;-)
There is no differnce between "eval list a b c d" and "list a b c d". Both
return a single list whose length is 4.
BUT,
set args "a b c d"
or
set args [list a b c d]
Now these are different:
list $args
eval list $args
The first returns a list of length 1; the second a list of length 4. This
is because eval has the effect of splitting the args list into individual
args in the command list, which was the original question's solution:
sys4:/prg/rickm> tclsh
% set args "a b c d"
a b c d
% set args [list a b c d]
a b c d
% list $args
{a b c d}
% eval list $args
a b c d
This a a bit more clear, perhaps:
% set args {"a b" "c d" "e f" "g h"}
"a b" "c d" "e f" "g h"
% list $args
{"a b" "c d" "e f" "g h"}
% eval list $args
{a b} {c d} {e f} {g h}
...RickM...
---------------------------------------------------------------------------
To unsubscribe from the Visual Tcl mailing list, please send a message
to [EMAIL PROTECTED] with "unsubscribe vtcl [EMAIL PROTECTED]" in the
message body (where [EMAIL PROTECTED] is your e-mail address).