|
On Wed, 16 Feb 2011 17:39:24 +0100, Mike Pall wrote:
Philippe Lhoste wrote:I always recommend to beginners in programming to replace magic numbers with constants, for readability and consistency.You mean like a21, a31, a32 and so on as in the original code? Yeah, that improves readability like 1000%. :-) [The original author used this solely because Python doesn't fold constants.] Magic comes sparingly, and any not-so-magical constants might as well live inline.
The problem is not so much readability than flexibility. If I inline a constant such as 32 in my code every time I refer to the size of an integer I will have a problem the day I will want to make it 64. In C I would not write "const int BITS = 32;" though, but rather "#define BITS 32". Maybe what we're lacking is a pre-processor? -- Pierre 'catwell' Chapuis