|
From: EricT <tw...@gm...> - 2025-10-21 02:53:25
|
Kevin:
If {=} parallels {*} as you mention, does that mean it would only work as a
separate word, and not inside quoted or unquoted strings? And what about
mixing command substitutions with numerical operations.
func {=}{[string length $str] + 1}
puts "result: {=}{$x + 1}"
set x prefix{=}{$x + 1}suffix
lrange $list 0 end-{=}{$x + 2}
This is important since $(expr) works in all these contexts because $
already triggers substitution there.
Eric
On Mon, Oct 20, 2025 at 7:31 PM Kevin Kenny <kev...@gm...> wrote:
> On Mon, Oct 20, 2025 at 7:22 PM EricT <tw...@gm...> wrote:
>
>> You're right that {=}{expression} avoids this particular incompatibility. I think {=} could potentially work, though my sense is it would require more extensive parser changes to handle quotes and bare words (where $ already works naturally). But I could be wrong about the implementation complexity.
>>
>>
> The parser changes are pretty minimal, and nearly parallel to the
> implementation of {*}. The {=} would be presumed to be followed by a
> 'word', with all the usual rules that implies.
>
> {=}{$a + $b} would be parsed by the ordinary balancing of curly braces,
> followed by processing the content as an expression.
>
> {=}[command], {=}"quoted string", {=}$var, etc, would all have natural
> meanings equivalent to applying [expr] to the substituted value.
> (Ordinarily, those uses should be advised against, since all these forms
> ask for double substitution and invite code injection attacks, but I can
> see them having their place in some specialized contexts, and the syntax is
> thereby rendered uniform.)
>
> (I'd actually favor {$} over {=}, and instead reserve {=} for the
> possibility of a new 'little language' for less cumbersome expressions (in
> particular, automatic $-substitution of barewords, and implementation of =
> for assignment. But that's a different idea altogether, and has had several
> rejected or abandoned TIPs over the years.)
>
> --
> 73 de ke9tv/2, Kevin
> _______________________________________________
> Tcl-Core mailing list
> Tcl...@li...
> https://lists.sourceforge.net/lists/listinfo/tcl-core
>
|