comp.lang.ada
 help / color / mirror / Atom feed
From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: if-then-no-else  Programming
Date: Wed, 20 Apr 2016 17:35:47 -0500
Date: 2016-04-20T17:35:47-05:00	[thread overview]
Message-ID: <nf9084$kku$1@loke.gir.dk> (raw)
In-Reply-To: 8328e4e6-97b7-49b6-92de-9f60181dc563@googlegroups.com


"Shark8" <onewingedshark@gmail.com> 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.



  reply	other threads:[~2016-04-20 22:35 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-19  2:24 if-then-no-else Programming Charles H. Sampson
2016-04-19  3:08 ` Dennis Lee Bieber
2016-04-19  3:19 ` Jeffrey R. Carter
2016-04-19  6:18 ` Nasser M. Abbasi
2016-04-19  7:55 ` Dmitry A. Kazakov
2016-04-19 12:17 ` G.B.
2016-04-20 22:26   ` Martin
2016-04-19 13:27 ` gautier_niouzes
2016-04-19 19:51 ` Randy Brukardt
2016-04-19 22:40   ` Shark8
2016-04-20 22:35     ` Randy Brukardt [this message]
2016-04-20  7:56   ` Charles H. Sampson
2016-04-20 11:26     ` Dennis Lee Bieber
2016-04-20 12:32       ` G.B.
2016-04-20 12:36         ` G.B.
2016-04-20 23:07     ` Jeffrey R. Carter
2016-04-19 20:32 ` Charles H. Sampson
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox