C's syntax

Andrew Dalke dalke at acm.org
Tue Oct 24 04:01:54 EDT 2000


Erik Max Francis wrote:
>[Writing "0 == a" instead of "a == 0" to catch accidental typos of
>"=" instead of "=="] is largely unnecessary.  It is a novice programming
> error, one that actual programmers do not make unless they are very green.

I accidentally typed "=" instead of "==" today, in Python code expecting
an expression.  I was glad to get the exception.  Oh, and I've been coding
for 17+ years and professionally for 5 of those, so I'm not very green.

Alex Martelli wrote:
> Visual C++ may not be "reasonable", but it's still one of the most
> widespread on the market, and does NOT give this warning at normal
> warning-levels (and the system header files spew oodles & oodles of
> warnings if you try to enable warnins at pedantic-level, so one
> does not normally use that).

Don't know about VC++ but I've seen ads for lint tools for MS Windows,
and I'll bet you can tell them to ignore system modules and only emit
messages for your own code.

In other words, if your tools aren't good enough, get better ones.

> If I recall correctly (it _was_ a while ago), vendor-supplied C
> compilers on many Unix systems did not supply that warning either.

That's why I compile under the vendor compiler and gcc (assuming they
aren't the same).  If possible, I compile under all the reasonable
compilers available to me.  I've been burned enough with making == vs. =
typos, bad varargs strings, accidently type mismatches, etc - even
knowing I make those errors! - that it's worth my time.

                    Andrew
                    dalke at acm.org







More information about the Python-list mailing list