Unnecessary Boolean Warning
Unnecessary Boolean Warning
- Subject: Unnecessary Boolean Warning
- From: Dale Miller <email@hidden>
- Date: Tue, 02 Aug 2011 17:57:20 -0700
Greg Parker wrote: "A warning on '==' inside of 'if' is ridiculous.
'==' is comparison for equality. "=' is assignment. Anyone who can't
at least keep these two straight shouldn't be doing programming."
I'm glad that my bosses failed to discover my incompetence in my
40+years of programming in FORTRAN,COBOL,CLIST,REXX,IBM360/370/Z
Assembler, and brief forays into other languages for conversion
projects. I've found C-based languages to be the fraught with bad
decisions in both syntax and semantics.
'==' is comparison for equality only in C-related languages. I tend to
think in terms of mathematics, where the '=' sign means 'comparison
for equality'. I've been unhappy with the choice of '=' for assignment
since learning FORTRAN many years ago. ALGOL at least used ":=" for
assignment, which like many very good ideas got buried for
unexplainable reasons. (Perhaps the users of those klunky teletype
machines felt a single extra character to type was an insufferable
burden.) Also, the idiotic basic assumption of C that 0 means false
and not 0 means true is responsible for another mistake-prone
construct where & means "and" in one context but it does not mean
"and" in another, and one must instead code "&&". It is disconcerting
that if A = 0x'0110' and B = '1001' then A & B returns true but A && B
returns 0, so "if (A && B)' is executed, the 'true' leg is not taken.
As I recall, at least at one point, the SOLARIS command processor
considered that the truth value of an integer was determined by the
low-order bit, so that 'true & true' always returned 'true' and 'A &
B' returned the expected bit-product (BOOLEAN 'and') of A and B.
I know the difference between "=" and ""==, I just tend to relapse
into my native and more logical language, and when forced to use a C-
variant, I need an assistant to remind me. My grandfather immigrated
to America from a German settlement in Russia. He insisted that the
family learn and speak English. However, when he hit his thumb with a
hammer, he still cried "Gott in Himmel!" I think Mr Parker was guilty
of hubris in his statement, and was totally out of line. Pride in
being facile with a crummy language does not justify denigrating
people who have finger-checks or memory lapses in dealing with some of
C's dumber constructs.
Dale Miller
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden