Skip to content

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 concat command 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

See Also

  • concat - The concatenation rules used when multiple arguments are provided
  • catch - Capture errors from evaluated scripts
  • subst - Perform substitutions without evaluation
  • uplevel - Evaluate script in a different stack level
  • namespace - Namespace management commands