summaryrefslogtreecommitdiffstats
path: root/doc/eval.n
diff options
context:
space:
mode:
Diffstat (limited to 'doc/eval.n')
-rw-r--r--doc/eval.n45
1 files changed, 15 insertions, 30 deletions
diff --git a/doc/eval.n b/doc/eval.n
index 448a459..d68db95 100644
--- a/doc/eval.n
+++ b/doc/eval.n
@@ -4,7 +4,7 @@
'\"
'\" See the file "license.terms" for information on usage and redistribution
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-'\"
+'\"
.TH eval n "" Tcl "Tcl Built-In Commands"
.so man.macros
.BS
@@ -14,6 +14,7 @@ eval \- Evaluate a Tcl script
.SH SYNOPSIS
\fBeval \fIarg \fR?\fIarg ...\fR?
.BE
+
.SH DESCRIPTION
.PP
\fBEval\fR takes one or more arguments, which together comprise a Tcl
@@ -23,22 +24,13 @@ fashion as the \fBconcat\fR command, passes the concatenated string to the
Tcl interpreter recursively, and returns the result of that
evaluation (or any error generated by it).
Note that the \fBlist\fR command quotes sequences of words in such a
-way that they are not further expanded by the \fBeval\fR command;
-for \fIany\fR values, $a, $b, and $c, these two lines are effectively
-equivalent:
-.PP
-.CS
-\fBeval\fR [list $a $b $c]
-$a $b $c
-.CE
+way that they are not further expanded by the \fBeval\fR command.
.SH EXAMPLES
-.PP
Often, it is useful to store a fragment of a script in a variable and
execute it later on with extra values appended. This technique is used
in a number of places throughout the Tcl core (e.g. in \fBfcopy\fR,
\fBlsort\fR and \fBtrace\fR command callbacks). This example shows how
to do this using core Tcl commands:
-.PP
.CS
set script {
puts "logging now"
@@ -56,42 +48,35 @@ for {set i 0} {$i<10} {incr i} {
}
.CE
.PP
+.VS 8.5
Note that in the most common case (where the script fragment is
actually just a list of words forming a command prefix), it is better
to use \fB{*}$script\fR when doing this sort of invocation
pattern. It is less general than the \fBeval\fR command, and hence
easier to make robust in practice.
+.VE 8.5
The following procedure acts in a way that is analogous to the
\fBlappend\fR command, except it inserts the argument values at the
start of the list in the variable:
-.PP
.CS
proc lprepend {varName args} {
- upvar 1 $varName var
- # Ensure that the variable exists and contains a list
- lappend var
- # Now we insert all the arguments in one go
- set var [\fBeval\fR [list linsert $var 0] $args]
+ upvar 1 $varName var
+ # Ensure that the variable exists and contains a list
+ lappend var
+ # Now we insert all the arguments in one go
+ set var [\fBeval\fR [list linsert $var 0] $args]
}
.CE
-.PP
+.VS 8.5
However, the last line would now normally be written without
\fBeval\fR, like this:
-.PP
.CS
set var [linsert $var 0 {*}$args]
.CE
-.PP
-or indeed like this:
-.PP
-.CS
-set var [list {*}$args {*}$var]
-.CE
+.VE 8.5
+
.SH "SEE ALSO"
-catch(n), concat(n), error(n), errorCode(n), errorInfo(n), interp(n), list(n),
-namespace(n), subst(n), uplevel(n)
+catch(n), concat(n), error(n), interp(n), list(n), namespace(n), subst(n), tclvars(n), uplevel(n)
+
.SH KEYWORDS
concatenate, evaluate, script
-'\" Local Variables:
-'\" mode: nroff
-'\" End: