From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on ip-172-31-65-14.ec2.internal X-Spam-Level: X-Spam-Status: No, score=0.8 required=3.0 tests=BAYES_50,FREEMAIL_FROM, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Received: by 2002:ad4:5d6d:0:b0:467:cb03:965e with SMTP id fn13-20020ad45d6d000000b00467cb03965emr33272794qvb.128.1654879116056; Fri, 10 Jun 2022 09:38:36 -0700 (PDT) X-Received: by 2002:a25:c711:0:b0:65c:9f45:64e5 with SMTP id w17-20020a25c711000000b0065c9f4564e5mr44441638ybe.189.1654879115847; Fri, 10 Jun 2022 09:38:35 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Fri, 10 Jun 2022 09:38:35 -0700 (PDT) In-Reply-To: <75d90749-242f-42b8-ba0b-299f7ac693e0n@googlegroups.com> Injection-Info: google-groups.googlegroups.com; posting-host=24.70.198.235; posting-account=GO34ygoAAABjKWQJiUlszgvYtyWwgCPW NNTP-Posting-Host: 24.70.198.235 References: <75d90749-242f-42b8-ba0b-299f7ac693e0n@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <3eb11358-66a5-4a87-b8ec-2328bbbb73acn@googlegroups.com> Subject: Re: Ada needs some modernization From: Brad Moore Injection-Date: Fri, 10 Jun 2022 16:38:36 +0000 Content-Type: text/plain; charset="UTF-8" X-Received-Bytes: 2183 Xref: reader02.eternal-september.org comp.lang.ada:63966 List-Id: On Tuesday, May 31, 2022 at 10:54:47 AM UTC-7, Matt Borchers wrote: > Throughout my career, I often find myself writing code similar to: > > if (A and B) or else (not A and C) then... > > and I always wished there was a better and clearer way to write this in Ada. Then along came if expressions. But, if expressions don't help that much with readablity although it is arguably simpler: > > if (if A then B else C) then... > I agree with the other comments, and in a case like this, I might consider writing an expression function to improve readability. Using cryptic letters for Booleans makes it difficult to assign a name to the expression function, but if you apply to less generic example, this becomes easier to do. For example, if A is renamed to Weekday, B means (time < 9:00pm), and C means (time < 6:00pm) you could write: function Shopping_Mall_is_Open return Boolean is (if Weekday then Earlier_than_9_PM else Earlier_than_6_PM); Then your other code would simply be,' if Shopping_Mall_is_Open then ... Brad