Re: marking mystery code

hagerman@ece.cmu.edu (John Hagerman)
16 Feb 1996 23:42:17 -0500

          From comp.compilers

Related articles
Re: Possible to write compiler to Java VM? ncohen@watson.ibm.com (1996-01-29)
Re: marking mystery code dewar@cs.nyu.edu (1996-02-13)
Re: marking mystery code dennison@escmail.orl.mmc.com (Ted Dennison) (1996-02-14)
Re: marking mystery code jmccarty@spdmail.spd.dsccc.com (1996-02-14)
Re: marking mystery code jgj@ssd.hcsc.com (1996-02-16)
Re: marking mystery code hagerman@ece.cmu.edu (1996-02-16)
Re: marking mystery code mnp@compass-da.com (Mitchell Perilstein) (1996-02-16)
Re: marking mystery code toon@moene.indiv.nluug.nl (Toon Moene) (1996-02-16)
Re: marking mystery code preston@tera.com (1996-02-17)
Re: marking mystery code rfg@monkeys.com (1996-02-19)
Re: marking mystery code kanze@lts.sel.alcatel.de (James Kanze US/ESC 60/3/141 #40763) (1996-02-21)
Re: marking mystery code xanthian@qualcomm.com (1996-02-24)
| List of all articles for this month |

From: hagerman@ece.cmu.edu (John Hagerman)
Newsgroups: comp.compilers
Date: 16 Feb 1996 23:42:17 -0500
Organization: Carnegie Mellon University
References: 96-01-116 96-02-138 96-02-156
Keywords: GCC, C

Robert Dewar wrote:
> Incidentally, the practice of marking suspicious code seems a good one
> to me. If code is being read by more than its author (often sadly not
> the case), then a reader will often wonder what something means, and
> not necessarily be able to tell if it is a bug, or if it needs more
> documentation, or perhaps some invariant that is assumed is not 100%
> right etc.


Ted Dennison <dennison@escmail.orl.mmc.com> writes:
> When ever I come across such code, I figure out what it does and
> either comment it, or rewrite it more clearly (or remove it). Is
> this an uncommon practice?


I remember seeing something related to this in comp.risks. (I tried
to find it in the archives without success -- is there a web site
providing such ability? http://catless.ncl.ac.uk/Risks gave nothing.)


As I recall, a programmer on a large project found some dead code and
deleted it; for some reason this caused a failure at a future date, so
the company adopted a policy of "Never delete code."


Sorry for the lack of details -- help me out here.


My style is (1) never be shy about adding comments, (2) always make
comments painfully clear, and (3) leave history -- code or comments,
as appropriate, with annotations. Number (4) would be to only replace
erroneous code and comments when I'm really sure I know what was wrong
and how to fix it, but I don't want to include this in the main list
because it has bitten me more than once.


~ John
[My recollection was that the code was something like this:


if(a<0) goto A;
if(a=0) goto B;
if(a<0) goto C;
halt; -- cannot happen


and it happened. -John]


--


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.