|
From: da S. P. J <pet...@fl...> - 2025-10-22 18:43:57
|
That doesn’t seem any better than “set x [= {$y + 1}]”
And the Unicode version gives me flashbacks to early Smalltalk and APL.
I started out in favor of the “$(...)” syntax but this is turning into creeping Perlism.
From: Florent Merlet <flo...@gm...>
Date: Wednesday, October 22, 2025 at 13:20
To: Zaumseil René <RZa...@kk...>, tc...@ro... <tc...@ro...>
Cc: et...@ro... <et...@ro...>, tcl...@li... <Tcl...@li...>
Subject: Re: [TCLCORE] [Ext] Re: TIP 672 Implementation Complete - Ready for Sponsorship
Another alternative proposal : set x [($y+1)] It is very readable, easy to write, there is eventually a unicode version set x 〖$y+1〗 1 . We define a new kind of substitution RULE [7'] Expression substitution : If a word contains an open bracket
Another alternative proposal :
set x [($y+1)]
It is very readable, easy to write, there is eventually a unicode version
set x 〖$y+1〗
1 . We define a new kind of substitution
RULE [7'] Expression substitution :
If a word contains an open bracket « [ » immediately followed by an open parenthesis « ( », then Tcl performs an Expression substitution. To do this it invokes the Tcl interpreter recursively to process the characters following the open parenthesis as a Tcl mathematical Expression. The Expression must be terminated by a close bracket « ] » immediately preceded by a closed parenthesis « ) ». The result of the expression is substituted into the word in place of the brackets-parenthesis and all of the characters between them. There may be any number of expression substitutions in a single word. Expression substitution is not performed on words enclosed in braces.
2. We create the test in ParseToken
... else if (*src == '[') {
if (src[1] == '(') {
// Expression substitution
// must finish by « )] »
// doesn't know how to do it...
} else {
// Command substitution
}
3. we create a -noexpr switch in the subst command
....
Examples :
inline expression : string range "my long sentence" 0 end-[($x+2)]
With native list expr enancement : .c create rectangle {*}[( $X , $Y, $X+100, $Y+100 )]
With multiples instructions enhancement : set multiexpr [( x = 1; y = 2; $x-$y, $y-$x )]
Readable, easy to type, test logically positionned in the C source code, no double substitution, avoiding confusion with variable substitution : This is the solution !
Florent
Le 22/10/2025 à 15:52, Zaumseil René a écrit :
And how will this be documented? Imho it should be mentioned in the dodecalogue.
Currently the used syntax is only used as array variable and not as math command.
I remember the big discussion on {*} syntax here.
Again, is this change really more readable and useable?
Is the benefit worth the additional syntax.
Why not create real benefit with p.e. a multiple set command ala tip 674.
Or a new math command without need of $.. access to variables.
Regards
rene
Von: Florent Merlet <flo...@gm...><mailto:flo...@gm...>
Gesendet: Mittwoch, 22. Oktober 2025 15:39
An: tc...@ro...<mailto:tc...@ro...>
Cc: et...@ro...<mailto:et...@ro...>; tcl...@li...<mailto:tcl...@li...>
Betreff: [Ext] Re: [TCLCORE] TIP 672 Implementation Complete - Ready for Sponsorship
So, everybody in the core team agree with the implementation of a new math-Expression substitution as a memlink command into the procedure in charge of variable name substitution ?
Le mer. 22 oct. 2025, 14:07, EricT <tw...@gm...<mailto:tw...@gm...>> a écrit :
Hi everyone,
I wanted to update you on the status of TIP 672 (expression substitution syntax).
The prototype implementation is now complete and available at:
https://github.com/rocketship88/tcl-tip-672-prototype<https://urldefense.us/v2/url?u=https-3A__github.com_rocketship88_tcl-2Dtip-2D672-2Dprototype&d=DwMDaQ&c=MASr1KIcYm9UGIT-jfIzwQg1YBeAkaJoBtxV_4o83uQ&r=BRyGRggIJd8TmKOhvEmGElFuDuCl3O5mT8opva3f-Uc&m=iT87BgHPQz_A0uNwlVbY84Y5W9eaZzr61JhUIsKkQHMwBqGb0HSqTCupNpvqyeMR&s=ZG5I9vay2CgB9hUAk2I-pkA-6Y6ofRO4-983kuM23Nw&e=>
The implementation has been parameterized to support both discussed approaches with a simple compile-time flag:
- Mode 1: $(expr) syntax
- Mode 2: $=(expr) or $^(expr) - configurable character
Key features:
- Comprehensive test suite (82 tests covering edge cases)
- Minimal code changes (~100 lines)
- Clean integration with existing parser
- Full Tcl test suite passes (only 3 expected differences)
There is one known issue: a minor memory leak in the synthetic command strings that will need attention during integration.
At this point, I need a sponsor to upload the code to a TIP branch on Fossil so the core team can review and decide whether to adopt the TIP and, if so, which syntax to use. I'm available for any collaborative work, questions, or modifications needed.
I'm grateful for all the feedback and support from the community. I look forward to the next steps in the process.
Best regards,
Eric
_______________________________________________
Tcl-Core mailing list
Tcl...@li...<mailto:Tcl...@li...>
https://lists.sourceforge.net/lists/listinfo/tcl-core<https://urldefense.us/v2/url?u=https-3A__lists.sourceforge.net_lists_listinfo_tcl-2Dcore&d=DwMDaQ&c=MASr1KIcYm9UGIT-jfIzwQg1YBeAkaJoBtxV_4o83uQ&r=BRyGRggIJd8TmKOhvEmGElFuDuCl3O5mT8opva3f-Uc&m=iT87BgHPQz_A0uNwlVbY84Y5W9eaZzr61JhUIsKkQHMwBqGb0HSqTCupNpvqyeMR&s=4iEQfafWSb-GM4h7dq1Qztghg-qOF6HjeF8W3XUHIzs&e=>
|