declaration of variables?

Jp Calderone exarkun at intarweb.us
Sun Feb 16 18:37:59 EST 2003


On Sun, Feb 16, 2003 at 05:39:06PM -0700, Steven Taschuk wrote:
> Quoth Jp Calderone:
>   [...]
> > With declarations, any time I wanted a new variable, I'd have to type an
> > extra keyword somewhere.  Any time I decided I didn't need a variable any
> > more, I'd have to go find where it was declared and remove it.  If you think
> > this isn't a significant hurdle, I recommend you go read some of the larger
> > C projects out there.  In many of them, you'll find all kinds of accrued
> > variable cruft - variables people declared, used, and then discarded, but
> > failed to remove the declarations.  [...]
> 
> I entirely agree that variable declarations cost more than their
> value.
> 
> Your latter point of orphaned declarations, however, has an easy
> answer: a compiler which issues errors for variables used but not
> declared should also issue warnings for variables declared but not
> used.

    exarkun:~/projects/test$ cat warnings.c

    int main() {
       int x;
       return 0;
    }
    exarkun:~/projects/test$ gcc -c warnings.c -o warnings
    warnings.c: In function 
ain':
    warnings.c:3: warning: unused variable 


  Maybe if it generated errors, instead... ;)

  There's another easy answer, of course - blame the lazy coders instead of
the language construct.  I think the "correct" course is a probably happy
medium somewhere 'twain the two.

-- 
 up 8 days, 4:28, 3 users, load average: 0.32, 0.11, 0.13
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20030216/3f35d90d/attachment.sig>


More information about the Python-list mailing list