digitalRead() returns HIGH or LOW
bool variables should be true or false (because "-1, 2 and -200 are all defined as true, too, in a Boolean sense".)
I understand that HIGH / LOW are not the same as true / false.
But in practical terms, is there any reason not to use this, because in my limitted experience it works just fine, and I've seen it used by coders apparently far more experienced than me.
There is no real reason not to do that. digitalRead() returns an Integer and will return HIGH or LOW (whichj are defined as 1 & 0) the result being cast to a bool, will result in true or false.
This particular thing should be fine, but it can lead you to doing things that are incompatible with the modern Arduino core library (even though they are supported by the older core used by the Arduino AVR Boards platform and other 3rd party boards platforms. Details here:
As explained, there is no real reason not to do what you have asked but it is wrong semantically and there is a chance that at some time in the future LOW, false and 0 may not have the same value. Unlikely, but possible
A commonly used construction
digitalWrite(pinNumber, !digitalRead(pinNumber));
used to flip the state of an output pin no longer works on some processors supported by the Arduino infrastructure due to a change in which HIGH and LOW are defined for them as pointed out by pert
In this particular case, there's little chance that it will ever be a problem.
Generally though, it's a bad idea to exploit what you know about how something is implemented because sooner or later it'll change and present you with a hard to figure bug.