Ada-Rapporteur-Group / User-Community-Input

Ada User Community Input Working Group - Github Mirror Prototype
26 stars 1 forks source link

Default value for Count in Ada.Containers.Vectors.Append. #76

Closed Blady-Com closed 5 months ago

Blady-Com commented 6 months ago

Current definitions in Ada.Containers.Vectors:

procedure Prepend  (Container : in out Vector; New_Item  : Element_Type; Count : Count_Type := 1);
procedure Append   (Container : in out Vector; New_Item  : Element_Type; Count : Count_Type);

Proposal definition: Add a default value for Count in Append as for Prepend: procedure Append (Container : in out Vector; New_Item : Element_Type; Count : Count_Type := 1);

sttaft commented 6 months ago

It turns out there is already an Append operation where the Count is implicitly one (paragraph 47.1/5). We had to handle Append and Prepend differently because Append needed to match the parameter profile expected for the "Add_Unnamed" part of the Aggregate aspect.

This is all explained in AI12-0400:

http://www.ada-auth.org/cgi-bin/cvsweb.cgi/ai12s/ai12-0400-1.txt?rev=1.5

Take care, -Tucker Taft

On Sat, Jan 13, 2024 at 5:34 AM Blady-Com @.***> wrote:

Current definitions in Ada.Containers.Vectors:

procedure Prepend (Container : in out Vector; New_Item : Element_Type; Count : Count_Type := 1); procedure Append (Container : in out Vector; New_Item : Element_Type; Count : Count_Type);

Proposal definition: Add a default value for Count in Append as for Prepend: procedure Append (Container : in out Vector; New_Item : Element_Type; Count : Count_Type := 1);

— Reply to this email directly, view it on GitHub https://github.com/Ada-Rapporteur-Group/User-Community-Input/issues/76, or unsubscribe https://github.com/notifications/unsubscribe-auth/AANZ4FMORROXDBOC2WWDZFDYOJPK3AVCNFSM6AAAAABBZHHNUOVHI2DSMVQWIX3LMV43ASLTON2WKOZSGA4DAMRTGIZDCMY . You are receiving this because you are subscribed to this thread.Message ID: @.***>

Blady-Com commented 6 months ago

Thanks for your explanation, it's make sens :-).

Note GNAT FSF 13.2 stil defines in aconvec.ads:

   procedure Append
     (Container : in out Vector;
      New_Item  : Vector) renames Append_Vector;
   --  Retained for now for compatibility; AI12-0400 will remove this.
sttaft commented 6 months ago

This was a very tricky fix, because it created some incompatibilities. I think this was a first step. It is probably time now to finish the job and implement what is defined by the Ada 2022 standard.

ARG-Editor commented 5 months ago

This question was adequately answered, so I am closing this Issue.