comp.lang.ada
 help / color / mirror / Atom feed
From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: anonymous records as tuples
Date: Mon, 12 Mar 2018 18:59:32 -0500
Date: 2018-03-12T18:59:32-05:00	[thread overview]
Message-ID: <p87494$ctd$1@franka.jacob-sparre.dk> (raw)
In-Reply-To: 290ddbd1-3aa1-4238-8737-51d8090af7d3@googlegroups.com

"Stephen Leake" <stephen_leake@stephe-leake.org> wrote in message 
news:290ddbd1-3aa1-4238-8737-51d8090af7d3@googlegroups.com...
> On Monday, March 12, 2018 at 2:17:08 PM UTC-5, Robert Eachus wrote:
>> On Monday, March 12, 2018 at 1:32:46 PM UTC-4, Stephen Leake wrote:
>> > I recently had to change a function that returned a single integer into 
>> > a procedure that returns two...
>>
>> What is wrong with something like:
>>
>> -- in Tree:
>>
>> type Return_Values is record
>>    Real : Integer;
>>    Virtual : Integer;
>> end record;
>>
>> function Count_Terminals (Index...) return Return_Values;
>> ...
>>
>> declare
>>   Returned: constant Tree.Return_Values := Tree.Count_Terminals(Index);
>>   Real: Integer renames Returned.Real;
>>   Virtual: Integer renames Returned.Virtual;
>> begin
>>   if Virtual = 0 then
>>      Next_Shared_Token := Next_Shared_Token - Real;
>>   end if;
>> end;
>
> That works, but is more verbose; I have to make up a name for the
> result type, when it's really an anonymous tuple of values. But I
> suspect the ARG would say the gain is not worth the cost.

I know *I* would say that, and I'd go even further, and say anonymous types 
in general are a bad thing for Ada. Ada is designed around named types 
(where two objects are the same only if the underlying types come from the 
same declaration), while anonymous types pretty much have to be matched 
structurally (if two types define the same structure, then they are the 
same).

There's nothing wrong with structural equivalence per-se, but mixing it with 
named equivalence tends to produce a hodge-podge of rules that mainly 
confuse everyone (implementers and users). And there are so many Ada 
constructs which assume a name is handy (type conversion, generic 
instantiation, and so on) that anonymous types tend to always have an 
incomplete set of capabilities.

But I'm not the ARG (even if it sometimes appears that way), so others may 
feel differently.

                                         Randy.


  reply	other threads:[~2018-03-12 23:59 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-12 17:32 anonymous records as tuples Stephen Leake
2018-03-12 18:01 ` Dmitry A. Kazakov
2018-03-12 19:17 ` Robert Eachus
2018-03-12 19:34   ` Stephen Leake
2018-03-12 23:59     ` Randy Brukardt [this message]
2018-03-13  2:51       ` Dan'l Miller
2018-03-13  8:28         ` Dmitry A. Kazakov
2018-03-12 21:09 ` Jeffrey R. Carter
replies disabled

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