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:a05:6214:1c83:b0:443:6749:51f8 with SMTP id ib3-20020a0562141c8300b00443674951f8mr51738535qvb.74.1654019686594; Tue, 31 May 2022 10:54:46 -0700 (PDT) X-Received: by 2002:a81:990f:0:b0:2f8:c347:d11a with SMTP id q15-20020a81990f000000b002f8c347d11amr63768941ywg.507.1654019686411; Tue, 31 May 2022 10:54:46 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer03.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: Tue, 31 May 2022 10:54:46 -0700 (PDT) Injection-Info: google-groups.googlegroups.com; posting-host=209.104.249.61; posting-account=1tLBmgoAAAAfy5sC3GUezzrpVNronPA- NNTP-Posting-Host: 209.104.249.61 User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <75d90749-242f-42b8-ba0b-299f7ac693e0n@googlegroups.com> Subject: Ada needs some modernization From: Matt Borchers Injection-Date: Tue, 31 May 2022 17:54:46 +0000 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Received-Bytes: 3457 Xref: reader02.eternal-september.org comp.lang.ada:63890 List-Id: 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 muc= h with readablity although it is arguably simpler: if (if A then B else C) then... What amendment can we suggest to the Ada syntax so the if expression be bet= ter written when used in an if statement? I know other languages support t= his and it often looks like A ? B : C or something similar. That's certa= inly not Ada-like IMO, but I can't think of something better. These same la= nguages often also have a null check operator A ?? B (where A and B are a= ccess types of the the same Type) such that if A is not null then A is retu= rned otherwise B is returned. So useful and helpful! ----- Again, I often find myself writing a loop to search for something and then = performing one or another action depending on the success of the search. T= his almost always requires some externally defined variable, like: --assuming arr'First is not Integer'First found :=3D arr'First - 1; for i in arr'Range loop if arr(i) =3D match then found :=3D i; exit; end if; end loop; if found in arr'Range then --do something A else --do something else B end if; Of course I could more the "do something A" into the if block within the lo= op, but I still need to know if I must run the alternate code afterward. I= t would be nice to avoid having to create a variable just to indicate the s= uccess state or indexing location found. Maybe something like: for i in arr'Range loop if arr(i) =3D match then --do something A exit; end if; then --do something else B end loop; The "then" part only executes after the loop terminates normally, i.e. only= when the loop does NOT exit early by "exit" or "return" statement. I think syntax enhancements like these could go a long way to making Ada fe= el like it is at least keeping up with modern languages and I think current= programmers expect "ease-of-use" syntax from today's languages. Other con= temporary modernized languages have taken ideas from Ada, but Ada has not c= ontinued to pioneer ideas as quickly. Perhaps that's by choice or design. Thoughts? Regards, Matt