3 ms·
The problem is mainly the square brackets that force one to go through strings, in my experience. Can't build something like "set foo [cmd $bar]" purely by usin
by BoingBoomTschak 1y ago
The problem is mainly the square brackets that force one to go through strings, in my experience. Can't build something like "set foo [cmd $bar]" purely by using [list ...] shenanigans, since list will quote stuff you don't want quoted.
- tracnar 1y agoTrue, I believe I mostly worked around that limitation by splitting off quoted from unquoted code into separate commands. So in your example "[cmd $bar]" would be in a separate unquoted command, probably putting it in a temporary variable, which can cause problems as it's hard to have a private scope when doing metaprogramming. You can also use "[list]" in the middle of code, but it gets more error prone, for example "set foo \[[list cmd \$bar]\]" For sure there is a lack of proper "code as data" constructs in Tcl, like you would find in Lisp.
- BoingBoomTschak 1y agoActually, you can see the "backslash hell" version here if you want to estimate the clarity gains: https://git.sr.ht/~q3cpma/tcl-misc/tree/f613898c3dcfa3ca958aab9fe5be959fc45171dd/item/util.tcl#L59 https://git.sr.ht/~q3cpma/tcl-misc/tree/f613898c3dcfa3ca958a...