comp.lang.ada
 help / color / mirror / Atom feed
From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: calling function but ignoring results
Date: Fri, 9 Jul 2021 21:57:27 -0500	[thread overview]
Message-ID: <scb2ao$ckl$1@franka.jacob-sparre.dk> (raw)
In-Reply-To: ikrlspFjskkU1@mid.individual.net

"Niklas Holsti" <niklas.holsti@tidorum.invalid> wrote in message 
news:ikrlspFjskkU1@mid.individual.net...
...
>> Is this "type-less" naming a copy of the popular omission schemes
>> like auto in C++? Optional type annotations in Swift, or Scala?
>
>
> I don't know all the origins of this language change, but it can be seen 
> as a correction because it avoids the wart in the earlier Ada form of 
> renaming, where a (sub)type name is included. The wart is that the 
> constraints of that (sub)type are essentially ignored, and so can be 
> misleading.

Right; the name of the type is often a lie vis-a-vis the subtype properties; 
moreover, it is often the case that the type is included in the renamed 
item:

    Foo : renames Some_Type'(Bar(Obj));

Repeating the type in such cases is not useful and violates DRY ("Do Not 
Repeat Yourself"):

   Foo : Some_Type renames Some_Type'(Bar(Obj));

We felt this was something that was better handled by style guides rather 
than imposing unnecessarily wordy syntax.

> AI12-0275 seems to be the main origin of this change:
>
> http://www.ada-auth.org/cgi-bin/cvsweb.cgi/ai12s/ai12-0275-1.txt?rev=1.9&raw=N

The actual motivation behind this change was a strong desire for a shorter 
way to write bindings in declare expressions. We tried a number of things, 
but they all seemed oddly special case. Eventually, we settled on using 
normal syntax throughout declare expressions, but simplified the syntax for 
renaming in all cases. The tipping point was noticing the duplication in 
examples like the above, along with the fact that the subtype given is 
ignored anyway.

If we were designing Ada from scratch, the subtype in a renames would have 
to statically match the nominal subtype of the name being renamed. But that 
wasn't required in Ada 83 and it would be way too incompatible to require 
now. (The reason that Ada 83 didn't require it? Jean Ichbiah didn't want to 
have to define "static matching" -- according to an old thread that John 
Goodenough dug up. Of course the Ada 9x team decided such a concept was 
necessary and added it to the language, so we ended up with most constructs 
using static matching, but renames being different.)

                                              Randy. 


  reply	other threads:[~2021-07-10  2:57 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-29 19:25 calling function but ignoring results Matt Borchers
2021-06-29 19:52 ` Jeffrey R. Carter
2021-06-29 20:34   ` Dmitry A. Kazakov
2021-06-30  6:06     ` Randy Brukardt
2021-07-09 18:14       ` G.B.
2021-07-09 19:20         ` Niklas Holsti
2021-07-10  2:57           ` Randy Brukardt [this message]
2021-07-12 15:56         ` Shark8
2021-06-30 10:17   ` Luke A. Guest
2021-07-01 18:07   ` Gabriele Galeotti
2021-07-02  7:32     ` Marius Amado-Alves
2021-07-03 11:35       ` Gabriele Galeotti
2021-07-03 11:46       ` Gabriele Galeotti
2021-07-03 19:11         ` Simon Wright
2021-07-04  7:22           ` Simon Wright
2021-07-06 23:07           ` Randy Brukardt
2021-06-30 10:26 ` Luke A. Guest
2021-06-30 19:31   ` Simon Wright
2021-06-30 23:06   ` Rod Kay
2021-07-01  0:06 ` Stephen Leake
2021-07-01  3:55   ` Randy Brukardt
2021-07-03 10:42     ` Stephen Leake
2021-07-03  1:22 ` Nasser M. Abbasi
2021-07-03  4:59   ` Matt Borchers
2021-07-03  7:37     ` Gautier write-only address
2021-07-03  7:42       ` Gautier write-only address
2021-07-03  7:57       ` Niklas Holsti
2021-07-03  7:46   ` Gautier write-only address
replies disabled

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