Path: utzoo!attcan!uunet!husc6!uwvax!oddjob!ncar!ames!xanth!kent From: kent@xanth.cs.odu.edu (Kent Paul Dolan) Newsgroups: comp.sys.amiga Subject: Re: Draco keywords Message-ID: <5727@xanth.cs.odu.edu> Date: 2 Jul 88 17:38:25 GMT References: <1809@van-bc.UUCP> <337@uwslh.UUCP> <6830@cup.portal.com> <1704@vaxb.calgary.UUCP> Reply-To: kent@cs.odu.edu (Kent Paul Dolan) Organization: Old Dominion University, Norfolk Va. Lines: 83 In article <1704@vaxb.calgary.UUCP> maloff@calgary.UUCP (Sheldon Maloff) writes: >In article <6830@cup.portal.com>, thad@cup.portal.com writes: >> STYLE is very important. After just completing a 300,000+ line C port, >> in retrospect I'm *GLAD* I used (for example): >> >> if ( condition) >> { >> for ( loop head ) >> { >> (loop body); >> } >> } >> >> MUCH much easier to see closure when the opening and closing braces are >> indented the same. > >This isn't the newsgroup for it, and this thread has deviated substantially >since I first posted it. *STYLE* is important. But nobody is going to >tell me that the above is easy to read ... its basically a dirivative of >the way Pascal code is written with BEGIN ... END. I would write the same >code as > > if (condition) { > for (loop head) { > loop body > } > } > >Why? I use an emacs at home and at work that does back paren/bracket/brace >matching. If that is sufficiently large that the two opening >braces are pushed off the top of the screen when I type }, emacs will >copy `for (loop head) {' into the minibuffer at the bottom of the screen. >Likewise for the second } typed. If I had indented with the style mentioned >above when I type `}' emacs would echo ` {' which means absolutely >nothing to me as to which brace I just matched. It all depends on the power >of the tools you have available, and *personal* taste. > >With that said I'm swallowing my original words, and am thinking of porting >corewars from C to Draco and giving the program a much needed graphical >interface. Seems no one sided with me about reverse keywords, so I'm >going to check the grass on the other side... > >(Corewars ... Scientific American, November 1986(?)) > This is as good an opening as any to promote a technique a friend, Paul Medlock, taught me when he taught me Pascal. This might seem really simple, but it is a really powerful aid in using a block structured language: close all constructs before filling them in! That way, in C, you never worry about what bracket you are closing; you always close something on the line after you open it, so lining stuff up is trivial. Example: create an if like: if () { } else { } or like if () { } else { } whichever you prefer, then make the insides. For me, in any language, this simple trick speeds up development enormously, cuts down bugs a lot, and avoids the problems mentioned above. There is no reason not to do it, given facility with a full screen editor. Another advantage in most languages, is that what you build will compile clean at any point. Sorry if everyone already does this, but from the comments above, this seems not to be the case. Kent, the man from xanth.