Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2007-10-27
20:52 • Closed ticket [1788984fff]: namespace code doc improvement plus 3 other c... artifact: 971b4504af user: msofer
2007-09-13
07:42 • Ticket [1788984fff]: 2 changes artifact: 7727e3d617 user: msofer
2007-09-06
05:44 • Ticket [1788984fff]: 4 changes artifact: dc474f310b user: jenglish
2007-09-05
20:58 • New ticket [1788984fff]. artifact: b2927338b8 user: dgp

[namespace code] doc improvement

Closed / Fixed1788984fffffffffffffffffffffffffffffffffCreated 19 years agoUpdated 19 years ago
Descriptionplain2007-09-05 20:58:23
"For example, suppose the command
set script [namespace code {foo bar}]
is invoked in namespace ::a::b.
Then eval "$script x y"
can be executed in any namespace (assuming the value of
script has been passed in properly)
and will have the same effect as the command
::namespace eval ::a::b {foo bar x y}."

For literal values like "x" and "y" this
advice is fine, but for a value containing
substitution characters, this doesn't work.
In order to prevent the substitution from
happening, the "..." quoting has to be rejected
as the script building tool.  This leaves
us with the safer [list]-based building schemes.

eval $script [list x y]

or

eval [linsert $script end x y]

are more generally correct solutions.
jenglishplain2007-09-06 05:44:34
Logged In: YES 
user_id=68433
Originator: NO

I don't think the docs currently guarantee that 

     eval [linsert $script end x y]

shall work.  However, it happens to be true, and it would be a good thing to guarantee.
msofer Ticket [1788984fff]: 2 changes [History diff]2007-09-13 07:42:56
msofer Closed ticket [1788984fff]. [History diff]2007-10-27 20:52:42
Log in (anonymous is fine) to add a comment.