Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!uunet!zaphod.mps.ohio-state.edu!usc!jarthur!mti!adrian From: adrian@mti.mti.com (Adrian McCarthy) Newsgroups: comp.lang.c Subject: Re: Managing error strings in C Message-ID: <1320@mti.mti.com> Date: 21 Jan 91 19:33:54 GMT References: <1991Jan10.122227@lotus.lotus.com> <620@necssd.NEC.COM> <1991Jan19.163652.9203@hemel.bull.co.uk> <2271@wzv.win.tue.nl> Reply-To: adrian@mti.UUCP (Adrian McCarthy) Organization: Micro Technology, Anaheim, CA Lines: 24 In article <2271@wzv.win.tue.nl> wietse@wzv.win.tue.nl (Wietse Venema) writes: >Error numbers, file names, line numbers etc. are often available as >global variables. These do not need to be passed to the message >formatter at all, if it understands format strings that look like: > > "Error %{error_number} on line %{line_number}" > >and consults the corresponding global variables to do %{...} expansion. This has its good and bad sides. Good: It's efficient and solves the problem at hand. Bad: If the message printer has to know about global variables specific to a particular program, it can't be re-used in another without modification. (This could be solved by using a structure that maps names used in the error messages to global variables used in the particular program. Handling the various types could be tricky.) Bad: It tempts programmers to put too much information into global variables which renders the program difficult to modify and maintain. Aid. (adrian@gonzo.mti.com)