Closed Glacia closed 3 years ago
To clarify, here is an example (From the same AI) of Empty_Vector as a function:
-- A positional vector aggregate:
V := ["abc", "def"];
-- Is equivalent to:
V := Empty_Vector (2);
Append_One (V, "abc");
Append_One (V, "def");
So Empty_Vector function should act as Reserve_Capacity (at least that is how i understand it).
Current Ada 202x Draft 20 4.3.5(6/5) says the following:
"The name specified for Empty for an Aggregate aspect shall denote a constant of the container type, or denote a function with a result type of the container type that has no parameters, or that has one in parameter of type Integer."
So Empty can be a constant, a parameterless function, or a function with one parameter.
Where did you find in the draft that it required a constant?
Thanks, -Tucker Taft
On Tue, Jun 11, 2019 at 11:22 AM Glacia notifications@github.com wrote:
In ai12-0212-1 it's implied that "empty" constants (ie Empty_Vector, Empty_Set etc) should be functions now, but in current Ada 202x draft (Draft 21) they're still constants. I suspect this is not intentional. Is it a bug?
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.
Sorry for not being clear. Yes, spec allows Empty for an Aggregate aspect to be constant or a function. But Ada containers were not changed to have "empty" functions. So the problem is not with container aggregates per se, but with Ada containers. For example in Vectors spec (A.18.2) there is no Empty_Vector function, although 4.3.5 examples show a Vector_Type (62/5) with Empty function. My understanding is that Empty_Vector function can be used to reserve memory space, similarly to Reserve_Capacity. If Empty_Vector is constant then on every append container is going to increase the vector capacity (177/2), which is not desirable for performance reasons.
OK, thanks for clarifying your question. We will talk about this at the upcoming ARG meeting. -Tuck
On Tue, Jun 11, 2019 at 7:20 PM Glacia notifications@github.com wrote:
Sorry for not being clear. Yes, spec allows Empty for an Aggregate aspect to be constant or a function. But Ada containers were not changed to have "empty" functions. So the problem is not with container aggregates per se, but with Ada containers. For example in Vectors spec (A.18.2) there is no Empty_Vector function, although 4.3.5 examples show a Vector_Type (62/5) with Empty function. My understanding is that Empty_Vector function can be used to reserve memory space, similarly to Reserve_Capacity. If Empty_Vector is constant then on every append container is going to increase the vector capacity (177/2), which is not desirable for performance reasons.
— You are receiving this because you were assigned. Reply to this email directly, view it on GitHub https://github.com/AdaCore/ada-spark-rfcs/issues/16?email_source=notifications&email_token=AANZ4FKRQA6C2LBSKZW4MTTP2AXNVA5CNFSM4HW7PSI2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODXOZBGA#issuecomment-501059736, or mute the thread https://github.com/notifications/unsubscribe-auth/AANZ4FOSCURMOUGUY4PKONDP2AXNVANCNFSM4HW7PSIQ .
AI12-0339 was approved at the recent ARG meeting in Warsaw in response to this issue. It is not posted yet on the ARG website (which currently shows 337 as the most recently created AI), but it will show up when the changes from that recent meeting are posted.
Nice! I guess this issue can be closed then.
On 6/18/19 5:59 AM, Glacia wrote:
Nice! I guess this issue can be closed then.
— You are receiving this because you were assigned. Reply to this email directly, view it on GitHub https://github.com/AdaCore/ada-spark-rfcs/issues/16?email_source=notifications&email_token=AMDGMTDIX4FIBKSQIT4NGGLP3DL4DA5CNFSM4HW7PSI2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODX6RDIY#issuecomment-503124387, or mute the thread https://github.com/notifications/unsubscribe-auth/AMDGMTHCSINP6XWLAR4IPODP3DL4DANCNFSM4HW7PSIQ.
Let's wait for the AI to be posted.
I think the AI addresses the problem in a noncontroversial way, but let's see if everyone else agrees after they've read it.
-- Steve
The AI has been approved as I understand it (http://www.ada-auth.org/cgi-bin/cvsweb.cgi/ai12s/ai12-0339-1.txt?rev=1.7), closing this issue. Thanks again!
In ai12-0212-1 it's implied that "empty" constants (ie Empty_Vector, Empty_Set etc) should be functions now, but in current Ada 202x draft (Draft 21) they're still constants. I suspect this is not intentional. Is it a bug?