<div dir="ltr">Pascal is about readability. A sentence like "if this variable is true do that" reads better than "if this variable do that". The danger is only when the variable type and the constant representing TRUE are not compatible. In C, since TRUE is usually an untyped #define, that can be hard to determine by the compiler or parser. In Pascal, it should be easy to detect when the two arguments aren't defined as identical types, even if the types are assignable to each other. But as long as True and the affirmative type of Boolean match, there should be no need for a warning. Only if True is Boolean, and the variable is ByteBool, or WordBool, or BOOL or some other type that doesn't use the same True/False values as Boolean should a warning be needed.<div><br></div><div>In other words, it isn't a style issue, it is a type compatibility issue.</div><div><br></div><div>Jeff</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Dec 15, 2014 at 7:46 AM, Jasper Neumann <span dir="ltr"><<a href="mailto:jn@sirrida.de" target="_blank">jn@sirrida.de</a>></span> wrote:<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello folks!<br>
<br>
MS>>> But the silly C programmer did "if (a == TRUE)".<br>
<br>
JN>> I have seen this kind of nonsense way too often,<br>
>> even in Pascal code.<br>
>>May I sincerely ask to include a hint/warning feature such as<br>
>> "Comparing booleans - bad style"<br>
>>in order to notify the programmer to think twice.<br>
>>This warning should be also active when using booleans<br>
>> as case expression.<br>
<br>
Marco van de Voor wrote:<br>
> This thread is about C style booleans.<br>
> For normal, safe behaviour, use Pascal booleans.<br>
<br>
Well, yes, but...<br>
I probably should better have changed the subject.<br>
My aim was to cure this kind of practice as it occurs on the Pascal side, although it might concern C compilers as well. I should propose this hint/warning for e.g. LLVM or GCC also.<br>
<br>
Best regards<br>
Jasper<br>
______________________________<u></u>_________________<br>
fpc-devel maillist - <a href="mailto:fpc-devel@lists.freepascal.org" target="_blank">fpc-devel@lists.freepascal.org</a><br>
<a href="http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel" target="_blank">http://lists.freepascal.org/<u></u>cgi-bin/mailman/listinfo/fpc-<u></u>devel</a><br>
</blockquote></div></div>