|
From: Brian G. <bri...@ea...> - 2026-03-04 18:39:51
|
On Mar 3, 2026, at 20:29, EricT <tw...@gm...> wrote: Ah yes. I see it says it is done as a pre-pass. And I now also know why the spaces and tabs on the next line are also removed. IMHO, however, I think this was a mistake, since it does tend to throw off reported line numbers in error messages, unless one's text editor understands this. I have many and not a one understands this distinction. That view is understandable. However, in Tcl, everything is a string first and foremost. A string is only a program when it is evaluated. Otherwise, it's just data. This is what makes things like CriTcl easy and possible. This concept is hard to appreciate at first. -Brian -eric On Tue, Mar 3, 2026 at 7:03 PM Brian Griffin <bri...@ea...<mailto:bri...@ea...>> wrote: Correct, because "\" is a duodecalogue<https://www.tcl-lang.org/man/tcl8.6/TclCmd/Tcl.htm%23M16> defined substitution. Substitutions are done before the statements are parsed. -Brian On Mar 3, 2026, at 12:53, EricT <tw...@gm...<mailto:tw...@gm...>> wrote: Hi Florent: Very nice implementation. With respect to <newline> being a command separator, this is the natural syntax of Tcl. Tcl allows for \<newline> as a continuation. That is why in my own implementation I simply map <newline> to ; (semi-colon) in a pre-pass. If I recall, in Tcl, the \<newline> is apparently removed, Not just apparently, but explicitly spelled out. :) since with this: proc foo123 args { set var \ "some string" } % info body foo123 set var "some string" I believe this also affects line numbering in error messages. regards, Eric On Tue, Mar 3, 2026 at 1:54 AM Florent Merlet <flo...@gm...<mailto:flo...@gm...>> wrote: Hi Eric, 1. you can write (1, 2, 3) or list(1, 2, 3) if you wish to : The implementation includes « list » into mathfunc. 2. Actually, newline are not command separators. I don't think I will make it like this, because I prefer to split a very long expression on many lines for readibility (espacially for matrix). For example : proc TensorialProduct {V U} { lassign $V x y z lassign $U u v w return [( a11 = $x*$u; a12 = $x*$v; a13 = $x*$w; a21 = $y*$u; a22 = $y*$v; a23 = $y*$w; a31 = $z*$u; a32 = $z*$v; a33 = $z*$w; (($a11, $a12, $a13), ($a21, $a22, $a23), ($a31, $a32, $a33)))] } 3. This is an error : % set x [(x=3;;$x+1)] missing operand at _@_ in expression "(x=3;_@_;$x+1)]" But this is valid : set L [( x = 2; y = $x*3; ($x, $y, $x*$y) )] puts L:$L L:{2 6 12} 4. You can write : set A [( x = 3; # set x # comment y = 4; # set y # result $y+$x)] Comments must begin after a semi-colon or a newline, but must finish with a newline. This works also : puts [( x = 2 ; # simple assignment of x y = $x*3 ; list($x, $y, $x*$y) # comment without ";" is OK at the end )] This doesn't : puts [( x = 2 # Comment without ";" before is NOK inside y = $x*3 ; list($x, $y, $x*$y) # comment without ";" is OK at the end. )] (bug to be investigated : TclStackFree: incorrect freePtr (0xa000262d0 != 0xa00026330). Call out of sequence? Illegal instruction) As ";" is map as a binary operator, it's waiting for an operand on its right. To turn around, you must give it something, beyond anything which is valid in expr, like for instance : % set x [( x=3; "A comment as a words in quotes"; 1.0e-10;# any valid number is possible { A comment as bracedword }; [ # A comment as # word script ]; $x+1 )] 5. This is working (TIP 282 made assign it right associative) : set M [( m12 = m21 = m13 = m31 = m23 = m32 = 0; m11 = m22 = m33 = 1; (($m11, $m12, $m13), ($m21, $m22, $m23), ($m31, $m32, $m33)) )] And returns : {{1 0 0} {0 1 0} {0 0 1}} 6. Yes it a new substitution rule only. But expr, or any alias of it, is there as a command. So, you can write expr {m12 = m21 = m13 = m31 = m23 = m32 = 0; m11 = m22 = m33 = 1} Moreover, as the TIP282 are in `expr` , you can use this feature in : `while`, `for`, `if` You may refer to the Eratosthenes Sieve example, the one with TIP282 integration, given in the updated TIP<https://github.com/florentis/tcl-ExprShorthand/blob/main/TIP-shorthand.md> proc sieve {n} { set L [lseq $n] for {set i 2} {(j = $i) < $n} {incr i} { while {(k = $i*$j) < $n} { lset L $k {} incr j } } return [lsearch -all -not -exact $L {}] } 7. bareword variable arithmetic : For the moment bareword as variable is only legal on the left side of the assignement operator. That follows this well known pattern of Tcl : set x $y <=> x = $y Will this TIP allows it ? Well, myself, I don't know how to do it yet. So It won't be allowed by myself yet... If someone has an idea... Personnally, my priority would go to introduce list assignement capabilities : set tM [((row1,row2,row3)=$M; (a11,a12,a13)=$row1; (a21,a22,a23)=$row2; (a31,a32,a33)=$row3; # transpose the matrix : (($a11,$a21,$a31), ($a12,$a22,$a32), ($a13,$a23,$a33)))] # could be made equivalent to : set tM [lassign $M row1 row2 row3 lassign $row1 a11 a12 a13 lassign $row2 a21 a22 a23 lassign $row3 a31 a32 a33 # transpose the matrix list [list $a11 $a21 $a31] \ [list $a12 $a22 $a32] \ [list $a13 $a23 $a33]] Thanks a lot for your interest. I hope you found in my reply all the answers to your questions. I'm very admirative of your work and get many ideas from it. You helped me a lot when you explained me the basics of Tcl pointer arithmetic. Without your explanations, I would have never enter in a big code like Tcl. I'm still waiting to hear people of the core team, but whatever will be their replys, I want to thank you for everything. Cordially, Florent Le 02/03/2026 à 23:02, EricT a écrit : Hi Florent: I haven't had a chance to study your implementation; however, with the addition of the = operator, you are very close to the project I implemented as a fork of Colin's original pure tcl "=" command. Here are some items that I implemented that I think you likely could add easily, if you haven't already done so. 1. Sometimes it's better to include a hint as to what is occuring. Your list operation, (1, 2, 3) might actually be better written as, list(1, 2, 3) And this is easily implemented as a mathfunc: proc tcl::mathfunc::list {args} { return [::list {*}$args] } 2. Treat a \n (newline) the same as ; (semi-colon) for command separators. Then you could easily have, set L [( x = 2 y = $x*3 list($x , $y, $x*$y) )] 3. Allow for null statements (which get ignored) so ;; or multiple newlines would work as well, so that could also be written: set L [( x = 2 y = $x*3 list($x , $y, $x*$y) )] 4. For compatibility with expr, allow on-the-line comments (if not already implemented) set L [( x = 2 ;# simple assignment of x y = $x*3 list($x , $y, $x*$y) # comment without the ; needed )] Allowing a null statement to be ignored (comment 3. above) is what would allow for both the use of ;# or # alone to work. 5. Allow for right associativity and chaining of the = (assignment) operator. This would allow for, set L [( a = b = c = 0 )] 6. I don't see a way that your implementation allows for an expression that is a complete command. That is, you appear to require it be an argument only. Is there some way to be able to write, [( a = b = c = 0 )] alone on a line as just a single command? 7. What will it take to support bare variable arithmetic? set L [( x = 2 y = x*3 list(x , y, x*y) )] Thanks for adding to the "neo-expr" project. Here's a reference to my fork of Colin's = command. https://github.com/rocketship88/colin-parser -Eric On Mon, Mar 2, 2026 at 6:32 AM Florent Merlet <flo...@gm...<mailto:flo...@gm...>> wrote: Dear Tcl Core team, Finally, I split the proposal in 4 repositories. They can be found at https://github.com/florentis<https://github.com/florentis/tcl-ExprShorthand/blob/main/TIP-shorthand.md> * The forth<https://github.com/florentis/tcl-ExprShorthand-index-list-TIP282> is for TIP 282 integration : It would allow us to write : set L [( x=2; y =$x*3; ($x , $y, $x*$y) )] # set x to 2, set y to 6, set L to {2 6 12} Cordially, Florent Le 02/03/2026 à 01:32, Florent Merlet a écrit : Dear Tcl Core team, Following my last developpements on the subject concerning a Tcl expression shorthand, I have produced a TIP. The text of this TIP<https://github.com/florentis/tcl-ExprShorthand/blob/main/TIP-shorthand.md> can be found at this url : https://github.com/florentis/tcl-ExprShorthand/blob/main/TIP-shorthand.md I splitted the proposal in 3 repositories : * The first<https://github.com/florentis/tcl-ExprShorthand> is for the basic expression shorthand. It would allow us to write : set A [( ... )] * The second<https://github.com/florentis/tcl-ExprShorthand-index> add the shorthand dedicated to array index. It would allow us to write : set B((...)) value * The third<https://github.com/florentis/tcl-ExprShorthand-index-list> add a native list handling in expression. It would allow us to write : set M((1+1)) [( (1,0,0) , (0,1,0) , (0,0,1) )] Each of those repositories contains the modified c-files from the Tcl9.1a trunk and the tclsh.exe that results from the compilation on my machine (Win 10 / cygwin + gcc). May you have a look and give me feedback ? Would someone of the core team be ready to sponsor it ? Cheers _______________________________________________ Tcl-Core mailing list Tcl...@li...<mailto:Tcl...@li...> https://lists.sourceforge.net/lists/listinfo/tcl-core -- ________________________________ Florent MERLET 4 rue Johann Strauss Logement 7 86180 BUXEROLLES ________________________________ Mél. : flo...@gm...<mailto:flo...@gm...> Tél. : 06 70 00 63 48 _______________________________________________ Tcl-Core mailing list Tcl...@li...<mailto:Tcl...@li...> https://lists.sourceforge.net/lists/listinfo/tcl-core _______________________________________________ Tcl-Core mailing list Tcl...@li...<mailto:Tcl...@li...> https://lists.sourceforge.net/lists/listinfo/tcl-core _______________________________________________ Tcl-Core mailing list Tcl...@li...<mailto:Tcl...@li...> https://lists.sourceforge.net/lists/listinfo/tcl-core |