Fixed Breaking change in Expression evaluation (.and.) in v17

Jan 12, 2009
9
0
The lazy evaluation of lines appears to have broken in v17. In v16, .and. appears to be evaluated lazily like in C, etc, but in v17 it doesn't work any more.

I have quite a few batch files with lines like
Iff %2. != . .and. not IsDir %2 Then
Echo %2 IS DIR
EndIff


Prior to v17 they were lazy evaluated, so passing only 1 parameter to the batch file resulted in the target line not being evaluated, and no error.

In v17, this is broken. It produces
TCC: C:\temp\1.btm [1] Unknown command "Then"
IS DIR
TCC: C:\temp\1.btm [3] Unknown command "EndIff"


I can rewrite the offending code as a series of Ifs, but it's pretty annoying, so I'll probably just drop back to 16 until if/when it's fixed.
 
May 20, 2008
11,400
99
Syracuse, NY, USA
The behavior is different in v17 (vs. v16). But I'm pretty sure the evaluations were never "lazy" (stop when the truth value is determined). Below, "foo" is echoed even though it was not necessary to evaluate the second conjunct/disjunct of the conditional expression.
Code:
v:\> ver

TCC  16.03.55  Windows 7 [Version 6.1.7601]

v:\> type ifftest.btm
iff a == b .and. %@exec[echo foo] == 0 then
echo bar
endiff

iff a == a .or. %@exec[echo foo] == 0 then
echo bar
endiff

v:\> ifftest.btm
foo
foo
bar
 

rconn

Administrator
Staff member
May 14, 2008
12,345
150
The evaluation was never lazy (it can't be since the parser doesn't know what combination of .AND. / .OR. / .XOR.'s you might have appended on the right side of the line).

The problem here doesn't have anything to do with the .AND., it's because of the missing argument for ISDIR. V16 had a hack to test for this; I've added it to v17 as well for build 62.
 
May 20, 2008
11,400
99
Syracuse, NY, USA
"C" type evaluation of logical expressions (stop expanding/evaluating when the truth value can no longer be changed) would be nice. I don't suppose it would be too hard to write such a routine, but it would need to be able to pass the simple expressions (EQ, NE, EXIST, ... long lost) back to TCC for evaluation. Rex, do you have any interest in such a thing?
 
May 20, 2008
11,400
99
Syracuse, NY, USA
Not too hard with a compiler; far from easy with an interpreter. I'd have to write a front-end preprocessor and evaluate everything twice (at least); I really don't think it's worth the trouble when the (rare) issues are easily worked around.
I was thinking more along these lines. You pass the complete conditional expression AS IS to a function (that I was considering writing). I parse its logical structure (and/or/xor/not ... probably built a tree of some sort). I evaluate the little pieces in some sensible order by passing them back to TCC for expansion and logical evaluation (TCC says just TRUE or FALSE). When I decide the truth value of the entire expression has been determined, I return with TRUE or FALSE possibly leaving parts of it unexpanded.
 
Similar threads
Thread starter Title Forum Replies Date
S Debugger keeps breaking with no break point set. Support 1
W Copy+Paste without breaking long lines as default? Support 1
R History window wrong size, can't remember size change Support 12
H Behavior change re piping a string to a Java program Support 1
Alpengreis [FORUM] After change the font, bold is without effect Support 7
R How to? Change TCMD tab font size in window menu Support 3
E How to change window title tcmd window - not tcc window Support 1
Alpengreis Small things to change in installer and after installed Everything Support 0
Charles Dye File completion change Support 11
T Change language in script Support 4
Jay Sage Change in Behavior of Activate Command Support 4
I Change value of a variable while debugging Support 3
T Change language after installation Support 4
D Fixed Change in behavior of variable expansion between 16 and 17 Support 3
Peter Bratton Change in scrput behaviour Support 4
A How to? Can't change directory ("cd") into system hidden files Support 13
J Change folder TCC starts in Support 2
vefatica A small change Support 7
ehab aboudaya How to? change ALT-F6 to another key Support 1
S How to? Change thread prefix? Easy "create thread" method? Support 8
S Terminology change Support 2
Peter Bratton @ping behavior change Support 2
T signaling firstcondition and cannot change colors Support 8
newbie Change percent-sign to anything-else in filename Support 24
nikbackm Change format of DIR totals Support 3
Stefano Piccardi did the forum software change in the last two days? Support 2
nikbackm LocalHistory change Support 3
D How to? Use regular expression with REN? Support 2
R v25 Regular Expression Analyser Support 2
vefatica SET /A var=expression=digits Support 3
D conditional expression: force numeric Support 6
D Catching the result of an evaluated script expression Support 0
rps Documentation Regular expression syntax link broken Support 1
Joe Caverly Conditional Expression Test of @SFN Support 4
cgunhouse Trouble with Relational Expression Support 4
M How to? Do a particular regular expression... Support 8
JohnQSmith Regular expression groups Support 15
M Just a verification regarding "Iff" and both "status test(s)" and "relational expression(s)"... Support 3
A How to? filter text stream with a regular expression Support 11
Phileosophos Can FFIND match file names with a regular expression? Support 19
fpefpe regular expression -- caseless Support 3
nickles Regular expression FOR/DIR Support 2
B @PERL[expression] definition? Support 2

Similar threads