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,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.140.41.115 with SMTP id y106mr3512262qgy.27.1461105638814; Tue, 19 Apr 2016 15:40:38 -0700 (PDT) X-Received: by 10.157.12.37 with SMTP id 34mr66673otr.4.1461105638684; Tue, 19 Apr 2016 15:40:38 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!feeder.eternal-september.org!news.glorb.com!7no4865801qgj.0!news-out.google.com!j7ni431igm.0!nntp.google.com!g8no4561714igr.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Tue, 19 Apr 2016 15:40:38 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=75.161.65.33; posting-account=lJ3JNwoAAAAQfH3VV9vttJLkThaxtTfC NNTP-Posting-Host: 75.161.65.33 References: <1mlx1gf.ebrae11jak5tyN%csampson@inetworld.net> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <8328e4e6-97b7-49b6-92de-9f60181dc563@googlegroups.com> Subject: Re: if-then-no-else Programming From: Shark8 Injection-Date: Tue, 19 Apr 2016 22:40:38 +0000 Content-Type: text/plain; charset=ISO-8859-1 Xref: news.eternal-september.org comp.lang.ada:30202 Date: 2016-04-19T15:40:38-07:00 List-Id: On Tuesday, April 19, 2016 at 1:51:07 PM UTC-6, Randy Brukardt wrote: > > Indeed, RRS has a style rule which is the exact opposite of his suggestion. > We require either an else or a comment that no else is needed for most if > statements. We found that we had cases like: > > if condition then > Do_Something; > end if; > > 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.