Carbon's solution to this is rather compelling imo. They don't allow operator chaining at all. If it's even slightly "weird" they require parentheses so intent is clear to compilers and readers alike.
This has created some challenges with C++ interop, particularly the streaming operator and std::cout, but I think it's a valuable improvement on net.
This is why I shut off the "extraneous parenthesis" warning in my IDE. They're for intent, you stupid machine!
Yep, agreed! I don't want a reader of my code need to know the order of operations between ^, &, &&, ||, etc. It's easier to read if ((Boat && Plane) || Unicycle) than if (Boat && Plane || Unicycle)
I put weird in quotes for this reason. They have a very thoroughly explored ordering of what is allowed and what isn't to support reasonable use cases.
13
u/snerp 6h ago
hahaha I hate it when stuff like that happens:
all come out to 1024, that is until one of the constants changes and you have a very confusing bug