wishlist item?
Fairlight
fairlite at fairlite.com
Wed Jul 12 16:47:25 PDT 2006
Just thought it might be nice to include a few things for DECLAREd variable
usage. I ran into a situation where I declared a variable, tried to access
it later, but had never actually assigned to it. It would be handy if the
debugger kicked out warnings (maybe via an env var setting) that warned you
if:
* A variable was declared as local, but is never assigned
* A variable is used in a comparison or as an rvalue but is never assigned
The first would help weed out unused variables, certainly. The second
helps with--quite frankly--stupid coding errors that never should be
introduced in the first place. Sure, it's my fault the code was sliced and
diced the way it was, but this -is- a trappable condition...why not notify
the programmer of their folly?
I could see omitting the second half of the feature request. The first
half makes a lot of sense though.
Watch, Bob Stockler'll post that his checksyn does this stuff already. :)
Actually, if it doesn't, I may write something that does as a standalone
program. But it would be cool to have rolled in.
As a case in point, I copied my own "copy a file" code from one project
to another. One critical part checks to see if the total amount copied
is less than the file size in a variable UpSize. If it's less, it loops
to copy another 8192 bytes worth, or however much is left if there's less
than 8K left. The giveaway was that the files all ended up 8192 in length,
meaning it never looped. An agonizing check and recheck of the code
revealed that the copy code looked fine. The logic was impeccable and had
always worked. Of course, the logic also depended on a part that was NOT
sliced and diced elsewhere in the code from the other projects that set the
value of UpSize from a lookup or from filesize() or indeed from anything.
And it's a local variable, so it wouldn't come from a global in another
table either.
Totally user error on my part, and a dumb one at that. But a 4GL should
help one along in those regards, no? :) Besides... There are a lot of
times people plan out code and allow for variables, then either drop
functionality or never implement it, leaving lots of unused variables
laying about. It'd be nice to have an easy way to wheedle out what to
strip to get cleaner code.
Just a thought...
mark->
--
Fairlight-> ||| "What if it's real, what if you're | Fairlight Consulting
__/\__ ||| just faking? What if you knew you |
<__<>__> ||| could? What if you get off on | http://www.fairlite.com
\/ ||| manipulating? Why does it feel so | info at fairlite.com
||| good?" --Le Bon |
More information about the Filepro-list
mailing list