APM: bugs

Wayne Walker wwalker at broadq.com
Mon Dec 2 09:17:50 CST 2002


In a sideline discussion, someone had been bitten by something like:

if ($foo = -1) { sub1; action2}

The bug is a missing = (= vs ==).

A friend of mine has given great advice, that I haven't implemented very
well yet.  He suggests that everytime you compare a scalar and a
constant put the constant on the left side:

if (-1 == $foo) { sub1; action2}

That way, if you do forget the second = sign:

if (-1 == $foo) { sub1; action2}

then you get a compile time error:

"Can't modify constant item in scalar assignment"

Once you get in the habit of putting the constant first, this very hard
to catch bug screams "Fix me" as soon as you make the mistake.

Of course, unfortunately, it does not help at all when comparing to
variables.

-- 

Wayne Walker

www.broadq.com :)  Bringing digital video and audio to the living room

And the "Wizard of Bill" says "Please ignore the crash behind the Windows."



More information about the Austin mailing list