eval
Concatenates arguments and evaluates the result as a script.
Syntax
tcl
eval arg ?arg ...?Parameters
- arg: One or more arguments to concatenate and evaluate
Description
The eval command concatenates all its arguments (using the same rules as concat), then evaluates the result as a Tcl script. This is useful for constructing commands dynamically or evaluating lists as scripts.
Argument Handling
- Single argument: When exactly one argument is provided, it is used directly as the script to evaluate.
- Multiple arguments: When multiple arguments are provided, they are concatenated using the same rules as the
concatcommand before evaluation.
Error and Result Propagation
Any error generated during evaluation is propagated back to the caller. Similarly, the result of the evaluated script becomes the result of the eval command.
Examples
Output
Output
Output
