I did not change the
way same-line
if works; it does not work at all.
I had planned to make a decision on whether to remove it or add same-line actions for other control flow statements (where possible). I was most likely going to decide to remove it, so don't expect to see it fixed.
I was under the impression that multi-expression, especially when in parens, could be used anywhere a normal expression could be used. I now get a parsing error. Is this a special case?
No. It
was a special case, but now it's the same as every other control flow statement and function-call-without-parentheses.
Within a parameter list (and not enclosed in (), [] or {}), comma always delimits parameters. With the old way of interpreting commas, the last parameter would appear to get pushed to the end, with unused parameters in between. For example,
MsgBox Text, Title, IGNORED, Options, or
MsgBox Text, Title, IGNORED, IGNORED, Options, because it would be interpreted as
MsgBox Text, Title, (IGNORED, IGNORED, Options). (But the v1 and v2 multi-statement operators differ.)
It is not true that multi-statement comma could be used anywhere a normal expression could be used. Any expression can contain a multi-statement expression
in parentheses, but outside of that comma had multiple meanings and was not always part of the expression. For instance, in previous alpha builds,
if condition, action was
not multi-statement comma, because
action was not part of the condition, and could be any statement, not necessarily an expression.
Using comma for this purpose seemed better (more intuitive) than the v1 way, which was to interpret
if x, y as a multi-statement expression. With If (or If, While, and maybe others) being the only place a comma can be followed by any statement (vs. only an expression), it seems like one of those "special rules" that do more harm than good.
You can still do
Code: Select all
if (t[idx]==na, (t[idx]:=dft, qty++)) ; One multi-statement expression (the final condition is 'qty++')
; or
if t[idx]==na ; One normal expression
t[idx]:=dft, qty++ ; One multi-statement expression (parentheses also allowed)
; or
(t[idx]==na) && (t[idx]:=dft, qty++)
(t[idx]==na) ? (t[idx]:=dft, qty++) : 0