Python + Borland - msvcrt = grr.

Tim Peters tim.one at home.com
Mon Apr 23 19:59:15 EDT 2001


[Paolo Invernizzi]
> I think that use before assignment is one thing, and assignment that is
> never used is another...
> But it seems to me that the Borland warning is right, as is an
> expression of inefficient code...

Hardly:  if the compiler is smart enough to detect that an assignment is
dead, it's also smart enough to refrain from generating any code for it.
That makes it a nuisance complaint.

> The "use before assignment" complain of other compilers is
> justified? So why dont follow the more efficient way of coding?

A) Under any decently optimizing compiler, it's not more efficient.

B) To shut up bogus use-before-def warnings from dumber compilers (and
   we *never* want to disable use-before-def warnings).

C) Because sometimes code is very complex, and under *modification*
   it's very easy to miss a new path in the code in which a local
   vrbl is suddenly not defined before use.  This isn't a nuisance
   in C, it's a disaster.  Initializing vrbls in complex C code is
   basic defensive coding practice.

> I dont work with a lot of compiler, but me too I'm a Borland
> fan <wink>.

Never used it, but sounds fine to me.  Surely they have options to shut up
nuisance complaints, though?  You can do whatever you like in *your* code,
but in the *Python* code base we try not to push compilers to their limits,
let alone readers' brains beyond them <wink>.

half-successful-anyway-ly y'rs  - tim





More information about the Python-list mailing list