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=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!feeder.eternal-september.org!gandalf.srv.welterde.de!news.jacob-sparre.dk!loke.jacob-sparre.dk!pnx.dk!.POSTED!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: if-then-no-else Programming Date: Wed, 20 Apr 2016 17:35:47 -0500 Organization: JSA Research & Innovation Message-ID: References: <1mlx1gf.ebrae11jak5tyN%csampson@inetworld.net> <8328e4e6-97b7-49b6-92de-9f60181dc563@googlegroups.com> NNTP-Posting-Host: rrsoftware.com X-Trace: loke.gir.dk 1461191748 21150 24.196.82.226 (20 Apr 2016 22:35:48 GMT) X-Complaints-To: news@jacob-sparre.dk NNTP-Posting-Date: Wed, 20 Apr 2016 22:35:48 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 X-RFC2646: Format=Flowed; Original X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.6157 Xref: news.eternal-september.org comp.lang.ada:30212 Date: 2016-04-20T17:35:47-05:00 List-Id: "Shark8" wrote in message news:8328e4e6-97b7-49b6-92de-9f60181dc563@googlegroups.com... > On Tuesday, April 19, 2016 at 1:51:07 PM UTC-6, Randy Brukardt wrote: ... >> and there would be a bug because nothing was done if condition was False. >> Errors of omission are the hardest things to find, and we hoped to reduce >> the number of them by at least requiring the programmer to think about >> all >> of the possibilities and documenting that they did so. Thus, the above >> would >> have to be written: >> >> if condition then >> Do_Something; >> -- else nothing needed. >> end if; >> >> so it's obvious that the reverse condition was considered. > > But we can do this natively in Ada: > > if condition then > Do_Something; > else > null; -- Nothing needed. > end if; > > I would think that there would be zero difference in code generation > between that and w/o the else. Sure, you could just require the "else". But for us, the comment is the important part, and the need to include an extra line can make the code harder to read (especially when we adopted this rule, as editors typically could only show 24 lines at a time). Thus we adopted an "else or comment starting with else" rule. Randy.