From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,c81dfd55bff3db44,start X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news4.google.com!proxad.net!feeder1-2.proxad.net!fdn.fr!gegeweb.org!aioe.org!not-for-mail From: =?iso-8859-15?Q?Yannick_Duch=EAne_=28Hibou57=29?= Newsgroups: comp.lang.ada Subject: Record aggregates assignments and the black-box and else Date: Fri, 07 May 2010 23:23:35 +0200 Organization: Ada At Home Message-ID: NNTP-Posting-Host: USAyO1MNnUeFapd/hHloTg.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org X-Notice: Filtered by postfilter v. 0.8.2 User-Agent: Opera Mail/10.53 (Win32) Xref: g2news2.google.com comp.lang.ada:11398 Date: 2010-05-07T23:23:35+02:00 List-Id: Hi Ada novellers, I've just had a quick check at the RM, to review what is the exact meaning of the black-box in aggregates assignment which are not initialization. I was to check if the black-box in this context (all but initialization), stands for the actual value or the default value defined in the record's full view declaration. Well, it seems this always stands for the default value, not for the actually assigned value of the corresponding members. [ARM 2005 4.3.1(19.1/2)] > For a record_component_association with <>, if the component_declaration > has a default_expression, that default_expression defines the value for > the associated component(s); otherwise, the associated component(s) are > initialized by default as for a stand-alone object of the component > subtype (see 3.3.1). I did not test on any compiler, as I wanted an answer from the standard's point of view. So the following type Record_Type is record A : Natural := 1; B : Natural := 2; end record; ... R : Record_Type; ... R.A := 3; ... R := (A => <>, B => 5) is expected to result in Record_Type'(A => 1, B => 5); Now let's come to the reason why I was checking about this. What I like with the aggregates assignments, is that the compiler will shout to wake you up as soon as you forget to think about the value of a member (particularly relevant if ever some members are added, this avoid you the bad story of out-of-date text sections). But what about the efficiency of this construct when it is to be used on a record which has some members already fixed and which should not change ? As said above, I like the aggregate assignment as a conscientious assignment where you assert you've though about each members in turn and none was sadly forgotten (a taste of safety). If I do : R := (A => R.A, B => 5); what is the most likely expected impact on the executable code efficiency, providing this kind of construct oftenly appears in multiple places of the source ? (the record type is obviously private and just accessed in the implementation). Do you think most compilers will use the presence of an R's self component as an hint for some kind of optimization when applicable ? -- No-no, this isn't an oops ...or I hope (TM) - Don't blame me... I'm just not lucky