Skip to content
Tcl Source Code View Ticket
Login

View Ticket

[subst] doc clarification

Closed / Fixed536838ffffffffffffffffffffffffffffffffffCreated 25 years agoUpdated 25 years ago
Descriptionplain2002-03-29 18:39:25
It should be noted that the -no* options to
[subst] only influence the "top level" of
substitution.  Even with -novar, variable
substitutions do take place with command
substitutions, and even with -nocommands,
command substitutions do take place within
variable substitutions (array indices).

% set a 1        
1
% subst -novar {$a [string equal $a 1]}
$a 1

% proc b {} {return c}  
% array set foo {c c b b [b] tricky}
% subst -nocommands {[b]$foo([b])}
[b]c
dgpplain2002-03-30 01:57:46
Logged In: YES 
user_id=80530


It should also be noted that [subst] can only have a
return code of TCL_OK or TCL_ERROR.  If a substitution
yields some other return code, notably TCL_RETURN, but
other extended return codes as well, they are effectively
converted to TCL_OK.

I seem to recall Brent Welch wishing for a means to
return extended return codes from [subst] for use in
web page template processing so that something like

subst {
# lots of template stuff with a
return -code 404 "Page not found"
# blah
}

could be used.
dgpplain2002-03-30 02:28:10
Logged In: YES 
user_id=80530

Actually, [return] acts much like [continue].

Said another way, [continue] is equivalent to [return ""].

Extended return codes too.
dkfplain2002-04-05 15:46:41
Logged In: YES 
user_id=79902

Care to submit a detailed description of what you're after?
dgpplain2002-04-06 04:19:20
File Added - 20637: sdoc.patch

Logged In: YES 
user_id=80530

Here's a patch.
dkfplain2002-04-18 20:28:16
Logged In: YES 
user_id=79902

Documentation change looks good to me; assigning back to you
for application.

(I was actually interested in what was meant by the handling
of TCL_RETURN, though I'd like to note that I've always
found it easier to pass that sort of thing using the
::errorCode variable.)
dgpplain2002-04-18 23:31:54
Logged In: YES 
user_id=80530

committed to HEAD (8.4a5)
Log in (anonymous is fine) to add a comment.

Attachments: