From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,8b756d9a0afb052a X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newscon06.news.prodigy.com!prodigy.net!newsfeed-00.mathworks.com!peer-uk.news.demon.net!kibo.news.demon.net!news.demon.co.uk!demon!not-for-mail From: Simon Wright Newsgroups: comp.lang.ada Subject: Re: Quick question about Ada code formatting. Date: Sun, 19 Feb 2006 22:23:44 +0000 Organization: Pushface Message-ID: References: <43f74bc0$0$13593$9b4e6d93@newsread2.arcor-online.net> <43f87015$0$13609$9b4e6d93@newsread2.arcor-online.net> NNTP-Posting-Host: pogner.demon.co.uk Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: news.demon.co.uk 1140387824 20160 62.49.19.209 (19 Feb 2006 22:23:44 GMT) X-Complaints-To: abuse@demon.net NNTP-Posting-Date: Sun, 19 Feb 2006 22:23:44 +0000 (UTC) Cancel-Lock: sha1:jIj2ROJcK2jOkbFAHcPcO1dN5K4= User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (darwin) Xref: g2news1.google.com comp.lang.ada:2999 Date: 2006-02-19T22:23:44+00:00 List-Id: Georg Bauhaus writes: > But indentation using 2 or 4 or 3 spaces is a typographical > issue. -gnaty without further qualification is rather unforgiving > when it forces reformatting of reused source code that happens not > to follow -gnaty's defaults. The same comment applies to space > before '(' and after "-- ". I'd prefer a less intrusive default > meaning of -gnaty. =gnaty was introduced to support AdaCore's in-house rules. I see no point in writing a massively complex stylistic guide, we need a tool (preferably an already-available one), so we just adopted -gnaty for new code. As I've said before, I have little time for the artistic approach if it leads to so-called engineers refusing to do what they're paid to. On the other hand, for re-used code (eg a matrix package, and even at one point AUnit) we switched off -gnaty; we had no intention of altering it, and indeed we had reasonably strict rules not to do so without showing that it was truly necessary (style _not_ coming under that heading!) > -gnaty could be improved, in my view, by separating layout > issues from issues that potentially affect how a piece of > code can be organized, and compiled. > > For example, on the one hand -gnaty marks > test.ada:2:04: (style) subprogram body has no previous spec > > and on the other hand, > test.ada:3:09: (style) space required The first case you mention seems to be the only -gnaty rule that has any semantic effect at all, all the others are indeed style. We also compile with -gnatwaL which is reasonably strict. I think there are a coule of warnings not switched on by -gnatwa -- yes, d (implicit dereferencing) and h (hiding) for a start. >>> There is a study (from Kent?, comparing MISRA C and other style >>> guides) that demonstrates how useless and wasteful typographic >>> sophistry is. >> >> Hmm, can't find anything like that on Google, any more pointers? > > The latest version I could find is here, > http://www.leshatton.org/Documents/MISRAC.pdf > > The wording seems to have softened since a version dated 2002/05/24. > The paragraph below Table 2 in that version starts: > > "The clear message from these studies is that a category A dominated > programming standard is a complete waste of everybody's time and money." > > (Category A means "inherently artistic", "subjectively or stylistically > based" rules. Category B.1 has "folklore rules" (e.g., no goto, never!) > and B.2 denotes rules for which there exist actual data from measuring > failures when not following these rules.) I found the paper quite confused. It says that -- without tool support -- a standard for C gets transgressed about once every 10 lines, regardless of whether it's mainly A-based (stylistic) or B-based (semantic). Clearly one needs compiler halp as much as possible. If it has a switch to warn about possibly-uninitialised variables one would be irresponsible not to use it. Ditto for style, surely? I also saw no evidence in it about whether code that didn't transgress stylistic rules had fewer semantic errors as well. I remember the Rational Environment. You had no choice about how your code was presented, because the internal representation didn't store layout; all you saw after the code had been internalised (semanticised was the word they used) was a view of it, prepared on the fly. One pretty soon got out of the habit of trying to force the system to do something else!