Newsgroups: comp.lang.c Path: utzoo!henry From: henry@utzoo.uucp (Henry Spencer) Subject: hardcoded constants Message-ID: <1988Dec13.172306.16195@utzoo.uucp> Organization: U of Toronto Zoology References: <1988Dec8.173158.11839@utzoo.uucp> <846@starfish.Convergent.COM> <9134@smoke.BRL.MIL> Date: Tue, 13 Dec 88 17:23:06 GMT In article <9134@smoke.BRL.MIL> gwyn@brl.arpa (Doug Gwyn (VLD/VMB) ) writes: >>How much hard-coding is too much? > >Almost any is too much. It is proper to use explicit constants when it >is clear what they mean and that they can never need to be changed. For >example, assigning 0 or 1 to initialize a counter is proper. Assuming >that 03 is always the right character code for a keyboard interrupt >character (i.e. ASCII ctrl-C) is not proper. The policy we try to follow is that if you must hard-code a constant, then it must be accompanied by a comment explaining why that particular number is there. -- SunOSish, adj: requiring | Henry Spencer at U of Toronto Zoology 32-bit bug numbers. | uunet!attcan!utzoo!henry henry@zoo.toronto.edu