comp.lang.ada
 help / color / mirror / Atom feed
From: Martin <martin@thedowies.com>
Subject: Re: if-then-no-else Programming
Date: Wed, 20 Apr 2016 15:26:37 -0700 (PDT)
Date: 2016-04-20T15:26:37-07:00	[thread overview]
Message-ID: <cf2b70e3-b40b-4126-b4d7-3d94f48914f6@googlegroups.com> (raw)
In-Reply-To: <nf57e2$lr5$1@dont-email.me>

On Tuesday, April 19, 2016 at 1:17:18 PM UTC+1, G.B. wrote:
[snip]
> Ada 2012 adds conditional expressions (in addition to the
> old nested functions that need to return). So, if the value
> that is to be assigned depends on Condition,
> 
>     Variable :=
>      (if Condition
>        then 1
>        else 3);
> 
> is another way of making sure that Variable is initialized,
> in *one* statement!
[snip]

I *much* prefer this style as the post-condition can't be accidentally missed (the post-condition being that 'Variable' is assigned a value). Leave 'if' statements for doing genuinely different responses.

-- Martin


  reply	other threads:[~2016-04-20 22:26 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 [this message]
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
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