|
From: Arjen M. <Arj...@de...> - 2025-10-20 20:46:31
|
Hi Eric, everyone,
Just for your information: The one extension that I know of that uses an anonymous array is stooop – Simple Tcl-only object-oriented programming – by Jean-Luc Fontaine. It is part of Tcllib.
Regards,
Arjen
From: EricT <tw...@gm...>
Sent: maandag 20 oktober 2025 19:45
To: Colin Macleod <col...@ya...>
Cc: tcl...@li...
Subject: Re: [TCLCORE] Prototype Implementation of TIP 672 - $(expr) Syntax
Caution: This message was sent from outside of Deltares. Please do not click links or open attachments unless you recognize the source of this email and know the content is safe. Please report all suspicious emails to "Ser...@de...<mailto:Ser...@de...>" as an attachment.
Besides for the jimtcl compatibility and its track record in use, there's another reason I like the $(expr) notation and that is that it acts in all ways like $var, so that what people have learned, such as how to use $ substitution in event callbacks, either by [list puts $var] or {puts $var} depending on whether or not they want delayed evaluation, would be similar for [list puts $(expr)] and {puts $(expr)}.
One other issue that came up in my testing was that my first upload to github a few days ago required that ()'s be balanced in the entire expression, including when there were command callbacks, such as
[string length abc(def]+$n
That would have needed to be escaped as abc\(def, but that restriction has been eliminated in the most recent code in my repository. It turns out that ()'s need to be balanced ONLY in the portions of an expression that are arithmetical, where, for example, (((1+2))) balancing would be required. The fix is in the latest upload to the repository. This makes it compatible with expr which also does not require balancing of ()'s in command callback strings whether bare or quoted.
One other fix was to eliminate the code that was changing newlines to spaces when found in an expression, since that was thought to be a problem, but turns out not to be the case. expr has no problem with newline as whitespace.
--Eric
On Mon, Oct 20, 2025 at 9:31 AM Colin Macleod via Tcl-Core <tcl...@li...<mailto:tcl...@li...>> wrote:
I would say {=}{expression} is more Tcl-ish, though two characters longer. It follows the precedent of {*}, and avoids the incompatibility of $(expression). I wonder if that could also be implemented by a simple macro-type substitution at the parsing stage, as Eric has proposed. If {=} was TIP-ed I would happily withdraw my competing TIP 676.
Colin.
On 20/10/2025 16:11, da Silva, Peter J wrote:
Obviously I think this is a great idea and I think anyone who actually uses $(thing) in production code is crazy, but when I brought it up it got shot down because it was apparently found in the wild in production code.
Pity it didn’t get into 9.0 :) but this would be a good era to do it in.
_______________________________________________
Tcl-Core mailing list
Tcl...@li...<mailto:Tcl...@li...>
https://lists.sourceforge.net/lists/listinfo/tcl-core
DISCLAIMER: This message is intended exclusively for the addressee(s) and may contain confidential and privileged information. If you are not the intended recipient please notify the sender immediately and destroy this message. Unauthorized use, disclosure or copying of this message is strictly prohibited. The foundation 'Stichting Deltares', which has its seat at Delft, The Netherlands, Commercial Registration Number 41146461, is not liable in any way whatsoever for consequences and/or damages resulting from the improper, incomplete and untimely dispatch, receipt and/or content of this e-mail.
|