Proposal for a new 'leval' command
This is a proposal. Feedback is welcome, including alternative names (such as lsubst). From the docs:
This command is similar to list in that it creates a list, but uses
the same rules as scripts when constructing the elements of the list.
It is somewhat similar to subst except it produces a list instead of a string.
This means that variables are substituted, commands are evaluated, backslashes are interpreted, the expansion operator is applied and comments are skipped.
Consider the following example.
set x 1
set y {2 3}
set z 3
leval {
# This is a list with interpolation
$x; # The x variable
{*}$y; # The y variable expanded
[string cat a b c]; # A command
{*}[list 4 5]; # A list expanded into multiple elements
"$z$z"; # A string with interpolation
}
The result of leval is the following list with 7 elements.
1 2 3 abc 4 5 33
This is particularly useful when constructing a list (or dict) as a data structure as it easily allows for comments and variable and command substitution.
Nice, though I think lsubst is a far more appropriate name than level, since I can't see how the base operation (substitutions) is related to eval.
I agree that lsubst is a better name
I plan to merge this as part of #348
Merged as part of #348 as lsubst