- Use a space before and after assignment operators
$foo = bar
- Do not use a space when incrementing or decrementing in calculations
Left ( Table::fieldName ; Length ( Table::fieldName ) -1 )
Left ( Table::fieldName ; Length ( Table::fieldName ) - 1 )
- Preferred comparisons
- ≠ over <>
- ≥ over >=
- ≤ over <=
Ouch. I generally love the work everyone has done on filemakerstandards.org. This one, however, is the sort of thing that makes me want to reach through the Internet and slap someone.
It's a terribly bad and idiosyncratic behavior of FileMaker that "-1" and "- 1" are sometimes the same thing. Sometimes. Very few other programming languages allow such ambiguity, and it shouldn't be encouraged. To me, this definitely seems like one of the ugly parts of FileMaker that we should pretend doesn't exist. Always surround operators with spaces, ESPECIALLY when incrementing or decrementing.
Interesting. Do you have any samples of when "- 1" doesn't work as "-1".
Quick, what does the following expression yield?
And this one?
What about this one?
It's never a good idea write "-1" unless you mean a negative value. If you write in multiple languages, the above expressions are invalid in some languages and produce different results in others. The rules in FileMaker are simple: the unary "-" operator has higher precedence than all the binary operators. You shouldn't have to know that to figure out your code, though. This recommendation requires you to recall this, and mentally "fix" the code to include the spaces around the subtraction operator.
Or, to put it more succinctly, correct code shouldn't look like a mistake. This recommendation looks like a mistake, and you will never see its like in a style guide for any other language.
I agree with the thought: Operators should use spaces.
But what I'm still confused about, how "- 1" and "-1" are different mathematically:
3 - 1 * 5 = -2
3 -1 * 5 = -2
3 - 1 *5 = -2
3 - 1*5 = -2
5 * -1 -4 = -9
5 * - 1 - 4 = -9
5 * - 1 -4 = -9
FileMaker consistently renders operators vs negative notation. At least in every expression I've ever thrown at it. I'm not opposed to the idea that I just have not run into it before, and thus have been lucky. But unless we are talking about a programming language that calculates as it reads Left-to-Right or Right-to-Left ( APL or SmallTalk ) or those used in very simple, basic calculators, you only need to understand basic Order of Operations.
I'm also of the opinion that one should never need to use a negative number in an expression.