Hi, For background, see this github discussion message: <https://github.com/LegalizeAdulthood/iterated-dynamics/discussions/300#discussioncomment-13510921> I haven't tried these out in FRACTINT yet, so I thought I'd ask here and maybe someone would know :) 1. Can an assignment operator be used in a sub-expression? e.g. is 'q=4+(w=6)/2' valid syntax? If so, what are the values of q and w afterwards? My expectation is yes, this is be valid syntax and the values should be q=7 and w=6. 2. Do the logical operators && and || have "short-circuit" behavior like they do in C/C++? My expectation is yes, meaning that e is unevaluated in the expressions '0 && e' and '1 || e'. No assignment expressions in e change variables, no values in the expression e are computed. Also, I note that the use of \ to continue a single logical statement across multiple physical lines doesn't appear to be documented for the formula type, although it's used in plenty of .frm files. Cheers, -- Richard -- "The Direct3D Graphics Pipeline" free book <http://tinyurl.com/d3d-pipeline> The Terminals Wiki <http://terminals-wiki.org> The Computer Graphics Museum <http://ComputerGraphicsMuseum.org> Legalize Adulthood! (my blog) <http://LegalizeAdulthood.wordpress.com>
OK, a little experimenting with the existing formula parser/interpreter yields these results (in case you were wondering): In article <E1uRvl7-00000008wkJ-0Nkg@shell.xmission.com>, Richard <legalize@xmission.com> writes:
1. Can an assignment operator be used in a sub-expression?
Nope. It can only be used in an assignment statement.
2. Do the logical operators && and || have "short-circuit" behavior like they do in C/C++?
No, they do not. Both arguments to && and || are computed before the operator is evaluated. Note: this testing was done with the 'C' code for type=formula, not against the DOS assembly implementation, which may be different. I think it would be safe to lift restriction 1 with no loss in backwards compatibility. For #2, there can be no side-effects to the arguments to && or ||, because restriction 1 is in effect. So the only consequence is that things might execute faster with shortcut behavior were implemented. For Iterated Dynamics, I've clarified these semantics in the documentation for 1.3, which releases this weekend :). -- Richard -- "The Direct3D Graphics Pipeline" free book <http://tinyurl.com/d3d-pipeline> The Terminals Wiki <http://terminals-wiki.org> The Computer Graphics Museum <http://ComputerGraphicsMuseum.org> Legalize Adulthood! (my blog) <http://LegalizeAdulthood.wordpress.com>
participants (1)
-
Richard