For
(a++-++b);
The parser knows, that there is no such thing as an +- or -+ operator on int. So it can split the expression in (a++ - ++b);
For
(a+++++b);
This can be (a+ ++... or (a++ +... but let's first have a look at a simpler expression:
int a = 100;
int b = 0;
-> int c=a+++b;
| Added variable c of type int with initial value 100
What is the desired result? a++ +b or a+ ++b? Well, it's interpreted as c=
(a++)+b; but it's bad style, since you have to have the details of operator precedence in head.
Is ++++b allowed, or a++++?
-> ++++b;
| Error:
| unexpected type
| required: variable
| found: value
| ++++b;
| ^-^
-> a++++;
| Error:
| unexpected type
| required: variable
| found: value
| a++++;
| ^-^
No. Why not? You could argue, that it is (a++)++; or ++(++b); But both include two steps, increment by one and returning a value, so for
a=100
b=0
c=a++;
c=++b;
we know, that c will become 100 or 1, in one case, the return is performed before incrementing (c=a++), in the other case after (++b);
Now what should happen with ++++b; or ++(++b); What get's returned?
Considering that, the only valid interpretation for a+++++b is a++ + ++b; There is no a+ ++ ++b, nor a+ +++ +b.
And a++ + ++b; works:
-> c=a++ + ++b;
| Variable c has been assigned the value 101
But since it is very rarely used, and not a big deal to insert two spaces, and more reader friendly, anyhow, we should live with the inconsistency, of a+++++b being rejected, while a++-++b is allowed, which doesn't make the latter a nice to read expression. Horizontal spaces make code better parsable for humans too, and that should be your main concern.
If you like to drive someone crazy, use
c=a--- - --b;
since there is this unary -, which is handy for producing negative values like -7.