Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

To the systems programmer, users and applications serve only to provide a test load.


devel / comp.lang.ada / Ada needs some modernization

SubjectAuthor
* Ada needs some modernizationMatt Borchers
+- Re: Ada needs some modernizationGautier write-only address
+- Re: Ada needs some modernizationDmitry A. Kazakov
+* Re: Ada needs some modernizationRandy Brukardt
|`- Re: Ada needs some modernizationJohn McCabe
+- Re: Ada needs some modernizationJeffrey R.Carter
+- Re: Ada needs some modernizationG.B.
`- Re: Ada needs some modernizationBrad Moore

1
Ada needs some modernization

<75d90749-242f-42b8-ba0b-299f7ac693e0n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=6959&group=comp.lang.ada#6959

  copy link   Newsgroups: comp.lang.ada
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: i2pn2.org!i2pn.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: mattborc...@gmail.com (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
 by: Matt Borchers - Tue, 31 May 2022 17:54 UTC

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...

What amendment can we suggest to the Ada syntax so the if expression be better written when used in an if statement? I know other languages support this and it often looks like A ? B : C or something similar. That's certainly not Ada-like IMO, but I can't think of something better. These same languages often also have a null check operator A ?? B (where A and B are access types of the the same Type) such that if A is not null then A is returned 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. This almost always requires some externally defined variable, like:

--assuming arr'First is not Integer'First
found := arr'First - 1;
for i in arr'Range loop
if arr(i) = match then
found := 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 loop, but I still need to know if I must run the alternate code afterward. It would be nice to avoid having to create a variable just to indicate the success state or indexing location found. Maybe something like:

for i in arr'Range loop
if arr(i) = 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 feel 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 contemporary modernized languages have taken ideas from Ada, but Ada has not continued to pioneer ideas as quickly. Perhaps that's by choice or design.

Thoughts?

Regards,
Matt

Re: Ada needs some modernization

<53126465-14f1-4d49-95a2-cc45fe142f42n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=6960&group=comp.lang.ada#6960

  copy link   Newsgroups: comp.lang.ada
X-Received: by 2002:a37:852:0:b0:6a5:f010:11bb with SMTP id 79-20020a370852000000b006a5f01011bbmr14305085qki.645.1654023948692;
Tue, 31 May 2022 12:05:48 -0700 (PDT)
X-Received: by 2002:a5b:691:0:b0:64d:ab44:f12e with SMTP id
j17-20020a5b0691000000b0064dab44f12emr59871311ybq.533.1654023948553; Tue, 31
May 2022 12:05:48 -0700 (PDT)
Path: i2pn2.org!i2pn.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 12:05:48 -0700 (PDT)
In-Reply-To: <75d90749-242f-42b8-ba0b-299f7ac693e0n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=2a02:1210:282b:1d00:7d81:9ff2:60bc:69a2;
posting-account=gRqrnQkAAAAC_02ynnhqGk1VRQlve6ZG
NNTP-Posting-Host: 2a02:1210:282b:1d00:7d81:9ff2:60bc:69a2
References: <75d90749-242f-42b8-ba0b-299f7ac693e0n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <53126465-14f1-4d49-95a2-cc45fe142f42n@googlegroups.com>
Subject: Re: Ada needs some modernization
From: gautier_...@hotmail.com (Gautier write-only address)
Injection-Date: Tue, 31 May 2022 19:05:48 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 1497
 by: Gautier write-only a - Tue, 31 May 2022 19:05 UTC

In you proposal, the "do something else B" appears before "end loop", which is not a very intuitive way to indicate a statement happening *after* the loop.
I suspect there is room for improvement...
Perhaps you would like to show an equivalent piece of code in a what you call a "modern language" ?

Re: Ada needs some modernization

<t75rqo$k0k$1@gioia.aioe.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=6961&group=comp.lang.ada#6961

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!aioe.org!siG8trSPtxwtkBCOZpBn8A.user.46.165.242.91.POSTED!not-for-mail
From: mail...@dmitry-kazakov.de (Dmitry A. Kazakov)
Newsgroups: comp.lang.ada
Subject: Re: Ada needs some modernization
Date: Tue, 31 May 2022 21:55:05 +0200
Organization: Aioe.org NNTP Server
Message-ID: <t75rqo$k0k$1@gioia.aioe.org>
References: <75d90749-242f-42b8-ba0b-299f7ac693e0n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="20500"; posting-host="siG8trSPtxwtkBCOZpBn8A.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.9.1
X-Notice: Filtered by postfilter v. 0.9.2
Content-Language: en-US
 by: Dmitry A. Kazakov - Tue, 31 May 2022 19:55 UTC

On 2022-05-31 19:54, 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...

Not same. In the former A may be computed twice.

> What amendment can we suggest to the Ada syntax so the if expression be better written when used in an if statement?

I newer felt it necessary. To me much more aggravating is code that
combines test/allocator with renaming, i.e.

if P /= null then
declare
X : T renames P.all;
begin
...
end;
end if;
------------
if X in T'Class then
declare
XX : T'Class renames T'Class (X);
begin
...
end;
end if;
-----------
P : access T'Class := new S;
X : S renames S (P.all);

If one could come up with some syntax for if-then-declare and
new-then-declare that would cover a lot of cases.

> I know other languages support this and it often looks like A ? B : C or something similar. That's certainly not Ada-like IMO, but I can't think of something better. These same languages often also have a null check operator A ?? B (where A and B are access types of the the same Type) such that if A is not null then A is returned otherwise B is returned. So useful and helpful!

Not in a strongly typed language IMO.

[...]

> Maybe something like:
>
> for i in arr'Range loop
> if arr(i) = match then
> --do something A
> exit;
> end if;
> then
> --do something else B
> end loop;

I usually use a nested function, e.g. search with a fallback:

function Get_Me_Something return Element is
begin
for I in arr'Range loop
if Arr (I) = match then
return Arr (I);
end if;
end loop;
return Defaul;
end Get_Me_Something

--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de

Re: Ada needs some modernization

<t765re$sj4$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=6963&group=comp.lang.ada#6963

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: ran...@rrsoftware.com (Randy Brukardt)
Newsgroups: comp.lang.ada
Subject: Re: Ada needs some modernization
Date: Tue, 31 May 2022 17:46:04 -0500
Organization: A noiseless patient Spider
Lines: 211
Message-ID: <t765re$sj4$1@dont-email.me>
References: <75d90749-242f-42b8-ba0b-299f7ac693e0n@googlegroups.com>
Injection-Date: Tue, 31 May 2022 22:46:06 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="e091d6e4097c0c85b8fa2a28aaea7cae";
logging-data="29284"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1999RopKgGxAmiDlvFKdHdJtr+upFsSh5M="
Cancel-Lock: sha1:I4gRhWvNmenzDELABD8d8z5y45M=
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.7246
X-RFC2646: Format=Flowed; Original
X-Newsreader: Microsoft Outlook Express 6.00.2900.5931
X-Priority: 3
X-MSMail-Priority: Normal
 by: Randy Brukardt - Tue, 31 May 2022 22:46 UTC

"Matt Borchers" <mattborchers@gmail.com> wrote in message
news:75d90749-242f-42b8-ba0b-299f7ac693e0n@googlegroups.com...
>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...
>
>What amendment can we suggest to the Ada syntax so the if expression be
>better written when used in an if >statement? I know other languages
>support this and it often looks like A ? B : C or something similar.
>That's >certainly not Ada-like IMO, but I can't think of something better.

Which is the rub. Ada is *not* about clever operators that hardly anyone
knows what they do. Indeed, the original proposal for Ada 2012 was an
"implies" operator. But we quickly found out that there are many people that
don't know off-hand what function an implies operator does. We were pretty
sure that every Ada programmer would understand an if expression.

Note that pretty much the only place that you should almost never use an if
expression is in the choice of an if statement. If you already can write an
if statement, you don't need an if expression! If expressions exist to make
initializations and assertions like (Pre/Post) easier to write.

So I would never write your expression in the first place (either of them).
I'd write something like:

if A then
if B then.
else
end if;
else
if C then
else
end if;
end if;

The contents of the arms should be short anyway, and typically will just be
a procedure call (and possibly some debugging, which is way easier if the
conditions are kept simple).

>These same languages often also have a null check operator A ?? B (where
>A and B are
>access types of the the same Type) such that if A is not null then A is
>returned otherwise B
>is returned. So useful and helpful!

Again, "utility" is not the criteria for Ada, rather understandability for
future maintainers is the primary criteria. The last thing we need is a
bunch of fancy but little used operators that some one cold when reading
some unfamilar code. (Yes, of course you can look them up on-line, but
stopping to doing so necessarily breaks your train of thought.)

And this construct fits nicely into an if expression, with no magic:

(if A /= null then A else B)

and this extends nicely to more likely cases:
(if A /= null then A elsif B /= null then B else raise Program_Error)

(Personally, I don't believe I've ever written something where such an
operator would be useful; one needs to check everything for null (you can't
usually can't assume B is nonnull, either). And the fall backs are generally
more complex than using some other object. Moreover, probably A should have
been declared null-excluding so it doesn't need to be tested in the first
place. :-)

-----

> 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. ...

.....
>for i in arr'Range loop
> if arr(i) = 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, ...

In Ada terms, an exit *is* normal completion, so you would need some
different terminology.

> i.e. only when the loop does NOT exit early by "exit" or "return"
> statement.

We've discussed the "continue" statement multiple times, and have always
ended up deciding that we are better off without it. (We've also discussed
allowing "exit" from blocks, but that turns into a mess when blocks and
loops get mixed, at least if one wants the code to do the same thing in Ada
2012 and in future Ada.)

We'ver essentially decided that it is better to use a goto in such rare
cases. The case you show above is similar.

for i in arr'Range loop
if arr(i) = match then
--do something A
goto Loop_Finished;
end if;
end loop;
-- We get here if the search item is not found:
--do something else B
<<Loop_Finished>> null;

Remember that every feature added to a language adds costs in
implementation, documentation, and in tools (analysis, checkers, etc.). A
feature needs to be quite useful in order to make the cut.

Aside: in the case above, I've usually written such loops like:

for i in arr'Range loop
if arr(i) = match then
--do something A
exit;
elsif i = arr'Last then
--do something else B
exit; -- Not really needed, but clearer what is going on.
end if;
end loop;

I've never been that happy with the duplication of the termination
condition, but this avoids any extra objects or any gotos.

If I was going to try to fix your problem with a language feature, I'd
probably try to define an attribute to avoid needing to duplicate the
termination condition. Something like:

Loop_Name: for i in arr'Range loop
if arr(i) = match then
--do something A
exit Loop_Name;
elsif i = Loop_Name'Range'Last then
--do something else B
exit Loop_Name; -- Not really needed, but clearer what is going on.
end if;
end loop Loop_Name;

(We probably would allow 'First and 'Last in such a case.) But this
technique doesn't really work with user-defined iterators (which don't
necessarily have a defined end), and I'm unsure if it is important enough
for another whistle.

>I think syntax enhancements like these could go a long way to making Ada
>feel like it is
>at least keeping up with modern languages and I think current programmers
>expect
>"ease-of-use" syntax from today's languages.

Ada has *never* been about "ease-of-use". It is about readability,
maintenability, and understandability. (See the "Design Goals" in the
Introduction -- http://www.ada-auth.org/standards/2xrm/html/RM-0-2.html.)

Enhancing readability might also enhance ease of use (for instance,
user-defined literals, target name symbols, and user-defined indexing all
were added to enhance readability by avoiding duplicative text that provides
little information), but it is never a primary goal for an Ada feature.

>Other contemporary modernized languages have taken ideas from Ada, but Ada
>has not
>continued to pioneer ideas as quickly. Perhaps that's by choice or design.

This is not true. Ada pioneers ideas all the time (see delta aggregates,
aggregate iterators, the target symbol, parallel stuff, etc. from Ada 2022).
What Ada does not do is waver from its core goal of readability and
maintainability. So we don't waste time with tiny features that are more
likely to harm readability and understandability than help. (Admittedly,
what features are really necessary and which are just nice to have is always
a personal choice.) Additionally, Ada has always been designed with a
"building-block" approach, so we don't provide (say) a semaphore, but rather
the tools (the protected type) to write one (and many other constructs). An
if expression is a building block; funny boolean operators with limited uses
are not.

I personally am not the least bit interested in worrying about ease-of-use
gadgets in other languages. If programmers need such gadgets to be
comfortable, they probably don't have the right mindset to be great Ada
software engineers in the first place. Saving a few characters in a few
expressions simply does not matter when compared to the effort needed to
define and document a good data abstraction (for instance, an abstract data
type and package).

There *are* features that probably would not interfere with Ada goals of
readability. One of them that comes up periodically is an "at end" clause so
one could write final wishes for a block/subprogram/package without writing
a bunch of exception handlers (which doesn't work in the case of abort!) or
one-time use controlled types. I'm sure there are others.

And certainly other languages have interesting features that Ada should
steal, the Rust owned access types would be an obvious example. (Don't get
me started on why Ada 2022 does not have those.) But "ease-of-use" is not
interesting, at least when it does not make readability better. (I want
people to replace "and" and "or" with if expressions as much as possible, as
those are much more understandable. No more operators please!)

Randy.

P.S. Man. did I spend a lot more time than I planned answering this. I hope
it helps.


Click here to read the complete article
Re: Ada needs some modernization

<dec53856-dae3-4f39-89f7-2cc4a55a5d44n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=6965&group=comp.lang.ada#6965

  copy link   Newsgroups: comp.lang.ada
X-Received: by 2002:a05:6214:c29:b0:45a:fedd:7315 with SMTP id a9-20020a0562140c2900b0045afedd7315mr52498828qvd.59.1654068265069;
Wed, 01 Jun 2022 00:24:25 -0700 (PDT)
X-Received: by 2002:a25:c803:0:b0:654:f985:9bbb with SMTP id
y3-20020a25c803000000b00654f9859bbbmr37718499ybf.267.1654068264828; Wed, 01
Jun 2022 00:24:24 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!feeder8.news.weretis.net!news.uzoreto.com!npeer.as286.net!npeer-ng0.as286.net!peer02.ams1!peer.ams1.xlned.com!news.xlned.com!peer01.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: Wed, 1 Jun 2022 00:24:24 -0700 (PDT)
In-Reply-To: <t765re$sj4$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=80.229.20.55; posting-account=WsVe0AoAAABheGmBjlLgPWhgIw6kxcL6
NNTP-Posting-Host: 80.229.20.55
References: <75d90749-242f-42b8-ba0b-299f7ac693e0n@googlegroups.com> <t765re$sj4$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <dec53856-dae3-4f39-89f7-2cc4a55a5d44n@googlegroups.com>
Subject: Re: Ada needs some modernization
From: joh...@mccabe.org.uk (John McCabe)
Injection-Date: Wed, 01 Jun 2022 07:24:25 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 1858
 by: John McCabe - Wed, 1 Jun 2022 07:24 UTC

On Tuesday, 31 May 2022 at 23:46:09 UTC+1, Randy Brukardt wrote:
<.. Snip.. >
> Randy.
>
> P.S. Man. did I spend a lot more time than I planned answering this. I hope
> it helps.

FWIW, I thought it was valuable. As I read through it I was constantly thinking of how I wish the people tweaking C++ (which, for various reasons, I'm using now) would take the same attitude, rather than trying to feed their own egos by adding all sorts of random rubbish that, due to the current 3 year cycle, tends also to be either temporary or half-baked random rubbish!

Thank you, Randy!

Re: Ada needs some modernization

<t78d0h$fa8$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=6972&group=comp.lang.ada#6972

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: spam.jrc...@spam.acm.org.not (Jeffrey R.Carter)
Newsgroups: comp.lang.ada
Subject: Re: Ada needs some modernization
Date: Wed, 1 Jun 2022 21:00:31 +0200
Organization: A noiseless patient Spider
Lines: 26
Message-ID: <t78d0h$fa8$1@dont-email.me>
References: <75d90749-242f-42b8-ba0b-299f7ac693e0n@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 1 Jun 2022 19:00:33 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="fd0902e16dcce8edaa19b32350322c66";
logging-data="15688"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18DHrRj2z7WWEPFPAm4iQ9b84QGY3uhkDQ="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
Thunderbird/91.9.1
Cancel-Lock: sha1:yAxzWTtJy5tISVBjxb2K4srAtlE=
In-Reply-To: <75d90749-242f-42b8-ba0b-299f7ac693e0n@googlegroups.com>
Content-Language: en-US
 by: Jeffrey R.Carter - Wed, 1 Jun 2022 19:00 UTC

On 2022-05-31 19:54, Matt Borchers wrote:
>
> What amendment can we suggest to the Ada syntax so the if expression be better written when used in an if statement? I know other languages support this and it often looks like A ? B : C or something similar. That's certainly not Ada-like IMO, but I can't think of something better. These same languages often also have a null check operator A ?? B (where A and B are access types of the the same Type) such that if A is not null then A is returned otherwise B is returned. So useful and helpful!

What you call "modernization" looks to me a lot like "repeating mistakes that
Ritchie made over 50 years ago".

"A ? B : C"? Or is it "A : B ? C"? If only there were a less cryptic, easier to
remember and understand way to express it. Something like "(if A then B else
C)", for example.

"A ?? B" might be "useful and helpful" if you use (or think in) a language with
pointers to objects everywhere, but in a language where such pointers are never
needed, like Ada, it is neither, especially since a conditional expression would
handle it just fine if it were ever needed.

> I often find myself writing a loop to search ...

When you write something for a second time, it's a signal to create a subprogram
or package to avoid writing it a third time.

--
Jeff Carter
"You empty-headed animal-food-trough wiper."
Monty Python & the Holy Grail
04

Re: Ada needs some modernization

<t79jf6$dre$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=6975&group=comp.lang.ada#6975

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: bauh...@notmyhomepage.invalid (G.B.)
Newsgroups: comp.lang.ada
Subject: Re: Ada needs some modernization
Date: Thu, 2 Jun 2022 07:56:53 +0200
Organization: A noiseless patient Spider
Lines: 39
Message-ID: <t79jf6$dre$1@dont-email.me>
References: <75d90749-242f-42b8-ba0b-299f7ac693e0n@googlegroups.com>
Reply-To: nonlegitur@notmyhomepage.de
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 2 Jun 2022 05:56:54 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="7758ebea916138817b411546f346cd56";
logging-data="14190"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/AcaxYKYuTlSaZgTmzGacZ9T+V7+16etE="
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0)
Gecko/20100101 Thunderbird/91.9.1
Cancel-Lock: sha1:1WqvVr+dDQ75Um9pYtEkkzGxir4=
In-Reply-To: <75d90749-242f-42b8-ba0b-299f7ac693e0n@googlegroups.com>
Content-Language: en-US
 by: G.B. - Thu, 2 Jun 2022 05:56 UTC

On 31.05.22 19:54, 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...
>
> What amendment can we suggest to the Ada syntax so the if expression be better written when used in an if statement?

I would try to fix the problem at where it is caused: ad hoc, unnamed
logical predicates! Syntactic sugar won't make these go away.

All those Boolean expressions have meaning, I suppose. The meanings
could be given a name. There would be facts, about A, B and C, that
make your statement true, some not. What does it state?

Compare this assembly of variables

((A and B) or else ((not A) and C)))

to a lambda expression or to a state machine's. Similar?
It is the lowest level of computation using a high level language.

> 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. This almost always requires some externally defined variable, like:
>
> --assuming arr'First is not Integer'First
> found := arr'First - 1;
> for i in arr'Range loop
> if arr(i) = match then
> found := i;
> exit;
> end if;
> end loop;

Again, there is an algorithm, typically Find_the_First, that will return
an index (or cursor). I'd use the return value in a conditional.

Re: Ada needs some modernization

<3eb11358-66a5-4a87-b8ec-2328bbbb73acn@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=7035&group=comp.lang.ada#7035

  copy link   Newsgroups: comp.lang.ada
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: i2pn2.org!i2pn.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: bj.moor...@gmail.com (Brad Moore)
Injection-Date: Fri, 10 Jun 2022 16:38:36 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 2183
 by: Brad Moore - Fri, 10 Jun 2022 16:38 UTC

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

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor