comp.lang.ada
 help / color / mirror / Atom feed
From: "G.B." <bauhaus@notmyhomepage.invalid>
Subject: Re: Ada needs some modernization
Date: Thu, 2 Jun 2022 07:56:53 +0200	[thread overview]
Message-ID: <t79jf6$dre$1@dont-email.me> (raw)
In-Reply-To: <75d90749-242f-42b8-ba0b-299f7ac693e0n@googlegroups.com>

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.

  parent reply	other threads:[~2022-06-02  5:56 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-31 17:54 Ada needs some modernization Matt Borchers
2022-05-31 19:05 ` Gautier write-only address
2022-05-31 19:55 ` Dmitry A. Kazakov
2022-05-31 22:46 ` Randy Brukardt
2022-06-01  7:24   ` John McCabe
2022-06-01 19:00 ` Jeffrey R.Carter
2022-06-02  5:56 ` G.B. [this message]
2022-06-10 16:38 ` Brad Moore
replies disabled

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