The goal is to simplify and make way for better syntax.
We remove some of the operators which make no sense or are just too seldom to actually be useful. Also, we want to completely remove the right-to-left precedence as known from C. The following changes need to be made to the operators:
Parentheses () | Same as before but are disallowed as the outmost operator. Not having right-to-left precedence makes this unnecessary. By disallowing this to be the first operator, one makes way for better syntax and potentially new features. |
---|---|
Field access . | Was left-to-right before. Stays the same. When used as the first operator, it implies this as its first operand. |
Pointer access -> | Deleted. |
Array access [] | Was left-to-right before. Stays the same. But array becomes an interlan class. |
Function call () | Was left-to-right before. Stays the same. |
Post increment ++ | Delete. |
Post decrement -- | Delete. |
sizeof and sizeof() | Was right-to-left. Delete the one which is not function-like and use the other one just like any real function. That way, it becomes left-to-right. |
Type casting () | Delete. Strong typing it is. |
Pre increment ++ | Delete. |
Pre decrement -- | Delete. |
Address operator & | Delete. |
Dereference operator * | Delete. |
Positive operator + | Was right-to-left but a unary operator. The only other useful operator it can couple with is the negative operator. And those two are commutative, so it makes no difference when they are now considered left-to right. This makes this a compiler problem only to detect the operators properly. Coupling with ! or ~ is semantically questionable and maybe should be warned by the compiler without parentheses. |
Negative operator - | Same as positive operator. |
Bitwise NOT operator ~ | Same as positive operator but even more should not be mixed with any other unary operator. |
Logical NOT operator ! | Same as bitwise NOT operator. |
Multiplication * | Was left-to-right before. Stays the same. |
Division / | Was left-to-right before. Stays the same. |
Modulo % | Was left-to-right before. Stays the same. Completely disallow negative values for now, they might be reintroduced in a later version. Add modulo for floating point. Add a warning if it is mixed with multiplication and division as this has no semantical meaning. |
Addition + | Was left-to-right before. Stays the same. |
Subtraction - | Was left-to-right before. Stays the same. |
Shift left << | Was left-to-right before. Stays the same. But maybe delete this operator and replace it with a function. |
Shift right >> | Was left-to-right before. Stays the same. But maybe delete this operator and replace it with a function. |
Lower < | Was left-to-right before. Stays the same. |
Lower Equal <= | Was left-to-right before. Stays the same. |
Greater > | Was left-to-right before. Stays the same. |
Greater Equal >= | Was left-to-right before. Stays the same. |
Equal == | Was left-to-right before. Stays the same. |
Unequal != | Was left-to-right before. Stays the same. |
Bitwise AND & | Was left-to-right before. Stays the same. |
Bitwise XOR ^ | Was left-to-right before. Stays the same. |
Bitwise OR | | Was left-to-right before. Stays the same. |
Logical AND && | Was left-to-right before. Stays the same. |
Logical OR || | Was left-to-right before. Stays the same. |
Condition ?: | Was right-to-left before. Define it to be non-cascadeable with another condition operator, then left-to-right is no problem anymore. Evaluate condition first, then either second or third operand. |
Assignment = | Was right-to-left before. Define it to have no return value. Cascading of assignments is no longer possible. Note that assigmnent is not the same thing as initialization, therefore it might still be used in an if condition or when defining a new local variable. |
Assignment += | Same as normal assignment. These operators simplify programming, therefore they are allowed. |
Assignment -= | Same as += assignment. |
Assignment *= | Same as += assignment. |
Assignment /= | Same as += assignment. |
Assignment %= | Delete. Too seldom to be useful. |
Assignment <<= | Delete. Too seldom to be useful. |
Assignment >>= | Delete. Too seldom to be useful. |
Assignment &= | Same as += assignment. Explicitely allow it for boolean values. |
Assignment |= | Same as += assignment. Explicitely allow it for boolean values. |
Assignment ^= | Same as += assignment. Explicitely allow it for boolean values. |
Sequence , | Delete |