[DGD] Re: About runtime errors

Josh Dady jpd at indecisive.com
Wed Jan 7 16:21:30 CET 2004


On Jan 6, 2004, at 8:02 PM, Erwin Harte wrote:

> You definitely want to "#include <trace.h>" and use
> err[TRACE_FUNCTION] instead of that err[2], err[TRACE_PROGNAME]
> instead of err[1], etc.
>
> Your code will make a lot more sense that way and you as well as
> whoever else gets to read the code later will thank you, in years to
> come.

The same style problem appeared in the lower_case function posted 
earlier; the following two expressions are equivalent to the compiler, 
but one is terrible code:

     if (str[0] == 'G') return;

     if (str[0] == 73) return;

I didn't bother to match the character code with the correct character 
code for upper-case G, and that's the whole point -- most software 
developers can't recite the simplest character encoding from memory, 
much less the extended and multi-byte varieties common today. More 
importantly, if the order of the values returned by call_trace() should 
change someday, you're far more likely to miss an expression like 
err[1] than the preprocessor is of missing err[TRACE_PROGNAME].


--
Joshua P. Dady
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: text/enriched
Size: 1104 bytes
Desc: not available
URL: <https://mail.dworkin.nl/pipermail/dgd/attachments/20040107/c231002b/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: PGP.sig
Type: application/pgp-signature
Size: 174 bytes
Desc: not available
URL: <https://mail.dworkin.nl/pipermail/dgd/attachments/20040107/c231002b/attachment.sig>


More information about the DGD mailing list