Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!eternal-september.org!.POSTED!not-for-mail From: et99 Newsgroups: comp.lang.tcl Subject: Re: can this work? Date: Tue, 25 Mar 2025 21:40:11 -0700 Organization: A noiseless patient Spider Lines: 54 Message-ID: References: <20250321163420.39ecbc0b40151daab77dcc27@domain.invalid> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Wed, 26 Mar 2025 05:40:13 +0100 (CET) Injection-Info: dont-email.me; posting-host="59ae5c87b4ec8e8f95ef3c15933bc1c0"; logging-data="1060374"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/QzNOplH1yTaRmAzGWbT4r" User-Agent: Mozilla Thunderbird Cancel-Lock: sha1:OfZbBHXg2rJ3KWIM8ec7uHDKmSA= In-Reply-To: Content-Language: en-US Bytes: 2986 On 3/22/2025 8:11 AM, Rich wrote: --snip-- > The for command is defined as always running expr on the middle > argument. Whether you get a loop that looks up variable contents by > that expr call to make the check dynamic, or a loop that runs expr on > the exact same static values for each iteration, depends upon what you > pass to the command. That depends upon what you write that is parsed > by the Tcl parser. > > > Actually, the manual for the [for] command does not say it runs [expr], rather, it only says: Then it repeatedly evaluates test as an expression; And the command [expr] is not mentioned at all. Also, in the page with the 12 rules, it never defines the word expression. The [if] command, however, does mention the use of [expr]: The if command evaluates expr1 as an expression (in the same way that expr evaluates its argument). I suppose one has to get deep into the weeds and fully understand the algorithm of [expr] to be able to parse it all. There, [expr] does define an expression. One item that took me forever to understand is why in most commands, words such as in these 3, set foo bar set foo {bar} set foo "bar" the 2 types of quotes don't change the result here from the unquoted version. But in [expr] and therefore also in the first argument to [if] and the second to [for] a string has to be quoted in one of the 2 ways. So that, if {$foo eq "bar"} .. if {$foo eq {bar}} .. is ok, but if {$foo eq bar} .. is not ok. And the reason is that, expr {$foo eq bar} also produces an error since operands in [expr] are not the same as tcl words. Here, [expr] complains about a bare word - something I've also not seen defined. Anyway, there's always something to learn here :)