Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!unmvax!nmt.edu!nraoaoc From: nraoaoc@nmt.edu (Daniel Briggs) Newsgroups: comp.lang.fortran Subject: Re: A Question of Style Summary: GOTOs aren't the problem -- labels are! Message-ID: <1991May22.212429.20215@nmt.edu> Date: 22 May 91 21:24:29 GMT References: <1991May21.140440.16964@m.cs.uiuc.edu> <1991May21.180713.1602@unixg.ubc.ca> <1991May22.093547.229@ktibv.uucp> Reply-To: dbriggs@nrao.edu (Daniel Briggs) Organization: National Radio Astronomy Observatory, Socorro NM Lines: 40 buckland@ucs.ubc.ca (Tony Buckland) writes: > There are a few people around (I'm not one of them, but I will > defend, although not entirely to the death, their right to be > themselves) who put labels on statements just as markers, with > no intention of ever referencing them. The technique can serve > as a way of locating all statements belonging to some class > defined in the programmer's head, or as a way of delineating > program segments, or as a labelling of statements you intend > to reference one day, or as a labelling of drop-through > statements for computed GOTOs. Et cetera. While few people would use Numerical Recepies code as a model of good coding style, there was one paragraph in the introduction of the book that stuck with me ever since I first read it. This argument alone is enough to convince me to never use an unneeded statement label as a shorthand for a precurser comment. This is from page 6: "Second, you {\it avoid}, insofar as possible, control statements whose controlled blocks or objects are difficult to discern at a glance. This means, in practice, that {\it you must try to avoid statement labels and {\tt GOTO}'s}. It is not the {\tt GOTO}'s which are dangerous (although they do interrupt one's reading of the program); the statement labels are the hazard. In fact, whenever you encounter a statement label while reading a program, you will soon be conditioned to get a sinking feeling in the pit of your stomach. Why? Because the following questions will, by habit, immediately spring to mind: Where did control come {\it from} in a branch to this label? It could be anywhere in the routine! What circumstances resulted in a branch to this label? They could be anything! Certainty becomes uncertainty, understanding dissolves into a morass of possibilities. (For the uninitiated, {\it ...} and {\tt ...} are TeXisms for italic and typewriter fonts.) -- This is a shared guest account, please send replies to dbriggs@nrao.edu (Internet) (505) 835-2974 Dan Briggs / NRAO / P.O. Box O / Socorro, NM / 87801 (U.S. Snail)