A subst-antial question
- From: "Busirane" <john.j.seal@xxxxxxxxx>
- Date: 21 Apr 2006 19:44:35 -0700
I've used [subst] before, and thought I understood it, but today it
surprised me. I guess subconsciously I was expecting it to work like
the parser, preserving word boundaries, but it doesn't. Here's a toy
example:
% package require comm
4.3
% set pairs {a 1 b 2 c 3}
a 1 b 2 c 3
Now I can create a local array:
% array set foo $pairs
% parray foo
foo(a) = 1
foo(b) = 2
foo(c) = 3
Here's a naive attempt to create a remote array using the same code:
% ::comm::comm send 51395 {array set foo $pairs}
can't read "pairs": no such variable
That's expected, since "pairs" isn't defined in the remote interpreter.
We have to substitute it here, and evaluate the results there. Here's
another naive attempt:
% ::comm::comm send 51395 array set foo $pairs
wrong # args: should be "array set arrayName list"
That's also expected, because of the implicit [concat] behavior of
[comm send]. How 'bout keeping the code in braces (to concat-proof it)
and substituting it?
% ::comm::comm send 51395 [subst {array set foo $pairs}]
wrong # args: should be "array set arrayName list"
Hmm... what's going on?
% subst {array set foo $pairs}
array set foo a 1 b 2 c 3
I was expecting a list of four words, which is what the parser
generates from the same expression. I can think of ways around this,
but am I missing something simple?
.
- Follow-Ups:
- Re: A subst-antial question
- From: Michael Schlenker
- Re: A subst-antial question
- From: Don Porter
- Re: A subst-antial question
- Prev by Date: Re: Anybody can provide me mysqltcl for UNIX and LINUX
- Next by Date: Re: A subst-antial question
- Previous by thread: After tk_messageBox exits, button status is changed!
- Next by thread: Re: A subst-antial question
- Index(es):