I did some investigation on how often an @function is used in the mail template. It is absolutely useless information, but I wanted to test the usage of Teamstudio Configurator from Lotus Script.
Here is a snapshot of the resulting view
Reading through the results I stumbled upon the @V2If formula. This formula is used 21 times in the mail85.ntf template.
But why should one use this @V2If in a template that would never be opened on a Notes 2 client. I looked in the Designer Help to find out if there is some difference betweeen the @If and @V2If .
To my surprise I found the following sentence in the help description for @V2If
Note In applications created with Lotus Notes prior to Release 4, the @If function is automatically renamed to @V2If during the upgrade to Release 4.
If I understand this sentence correct, all @if entries in the code of an application created in Notes 3 are replaced automatically by @V2If when you convert the application from Notes 3 to Notes 4.
IMHO this must be a typo, because this would not make any sense. @IF was introduced in Notes 3. Why should one convert this to the old @V2IF when you are obviously using Notes 4?
Oh listen, a sack of rice fell over in the Yunnan district …
I’m going to seriously date myself by posting this answer…
It’s because the behavior of @If changed from version 2 to version 3. Prior to 3, @If did something very strange in software terms: it executed ALL the branches, regardless of whether the conditional was true or false. It then picked which one of those branches to return as the result based on the condition. But every branch was evaluated first.
Now you might think that’s crazy, but you have to remember, prior to 3, it was impossible for a statement in an @If to do ANYTHING but return a simple value. There were no @functions that had UI or data consequences. The formula could only affect the field it was currently in, and it could only ever result in the output of a single value. No other operations were allowed.
So it really didn’t matter whether every branch was evaluated or not, except in terms of performance. Take @If(x=y; x+y; x*y) Does it matter if you add x+y and put that in a memory register, then also multiply x*y and put that in a memory register, and THEN decide which one you’re going to point to? It doesn’t really make any difference.
But with v3, Iris introduced @functions that had both UI and data consequences. Now you could have @SetField, @SetEnvironment, and @Prompt. So now it DID make a difference which branch was executed, because if the conditional was false, you certainly don’t want to be prompting the user for information or writing values to fields.
So that meant Iris had to fork the notion of @If. They were really creating a brand new concept of conditionals that was fundamentally different in how they behaved. So they changed the internal token representation. Now they said “the old token for @If will be shown in the editor as @V2If, to clearly distinguish it from the new @If. But developers should know that the only reason to use @V2If is because they want to make something backward compatible to version 2. Otherwise, just @If is safer and more efficient.”
Honestly, there was some consternation at the time as to whether they should have left the old one as @If, and named the new one @V3If. Remember, this was the first time there’d ever been a language change in the product — it was only on it’s 3 version, and there were only a handful of it actually writing for it at the time. Clearly, the pattern stuck, as we later saw @V3UserName (differentiated because of some confusion over hierarchical names) and @V4UserAccess (I don’t remember why this changed — maybe privileges vs. roles?)
I have no idea if @V2If retains it’s old behavior since the formula engine rewrite in R6. It would be funny if it did.
It strikes me as pretty funny that the mail template still has 21 instances of @V2If. There’s 3 possible reasons for that: 1) they template is still backwards compatible to version 2; 2) there are code elements in the template that have not been touched by a human since version 4; or 3) the internal developers know something we don’t about @V2If, and it’s somehow faster or better than the regular @If in certain situations, and so it’s an optimization.
It would be fascinating to know which of these is true.
Is there some magic to getting my comment to appear? 🙁
magic called patience … 😉