Forum > General
FPC and bitwise negation
(1/1)
Mike James:
I'm interested in language design and I'm writing a compiler for a Oberon-like language using Coco-R. The bitwise negation is define as :
--- Code: ---Factor = /* others */ | "NOT" Factor.
--- End code ---
This means that the following code fragment is legit:
--- Code: ---mybool := NOT NOT NOT NOT mybool;
--- End code ---
I checked the same code fragment under FreePascal and this allows it also.
It got me thinking: Should it be flagged as a warning (or even a mild rebuke :D) and when would it ever be useful to allow such a construction?
-=mike=-
marcov:
Repeated unary NOTs are fairly easily optimizable, and logically sound (though redundant) so why would one unnecesarily burden the compiler (and increase warning/hint noise)?
Both the compiler developer and user have better things to do.
Only exception I can imagine is compilers and, more importantly, source analysers for training/educational purposes.
Navigation
[0] Message Index