-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[RFC] Fixed array lower bound #38
Conversation
considered/rfc-lower-bound.rst
Outdated
|
||
.. code-block:: ada | ||
|
||
V : A (10); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This syntax is intrinsically ambiguous. A(n)
could mean either A (<lower bound> .. N)
(as you probably intended) or "an array of N elements", i.e. A (<lower bound> .. <lower bound> + N -1)
. I'm not sure it is worth it to introduce another syntax oddity, and I would suggest dropping it altogether.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, this part of the proposal might need to be removed or a different syntax used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah - I agree with @yakobowski and @jeremiahbreeden - I'm not to happy with that bit either. I'll move this to the "Future possibilities" section.
There are in fact two ways (I know of) to force a fixed lower bound:
and
Maybe the compiler could be made smarter to optimize code in both cases. I think your proposed change is very heavy in comparison to the expected performance gain. |
There are things to consider here though:
I do this one a lot, but I will say this is one of the few cases where I feel like Ada pushes me into a bad or unfortunate design. I'm not using a record because my software problem is better solved by a record. I'm using a record because Ada can't do this any better way. This adds noise to my designs and makes it harder to understand for the average and novice reader (I've experienced trying to explain what this is first hand).
I would like this if the compiler could enforce it statically when possible (and ideally without assertions enabled), but this appears to be a dynamic only predicate, which is unfortunate. But that means Ada would need better compile-time support defined in the language spec. Sure a compiler vendor could do it themselves, but not being able to rely on the languages rules for stuff like is an awful place to be. One of the best things C++ did (at least for the embedded landscape) was the constexpr rules. It gave a specific set of rules for when things "must" be evaluated at compile time by the compiler but the flexibility to let the same code be used dynamically if the inputs were not compile-time. |
This one is actually slightly misleading as Len is really the Last element of the array, not its length. But yes, and documented in the proposal.
I think this one will open a whole bunch of difficult questions. What if you want more than this condition in the predicate? Do you have another predicate? Overall, I would argue that relying of arbitrary predicate analysis for structural decision is a bit weak. |
An existing Ada 202X AI, on hold, has a related proposal:
http://www.ada-auth.org/cgi-bin/cvsweb.cgi/ai12s/ai12-0246-1.txt?rev=1.3
…-Tuck
On Fri, Feb 28, 2020 at 9:29 PM QuentinOchem ***@***.***> wrote:
This is an initial proposal allowing to fix the lower bound of an array
type, in an attempt at fixing some Ada-specific performance footprint.
------------------------------
You can view, comment on, or merge this pull request online at:
#38
Commit Summary
- Initial proposal
File Changes
- *A* considered/rfc-lower-bound.rst
<https://github.com/AdaCore/ada-spark-rfcs/pull/38/files#diff-9fcb9eb63e86a10e3ac394d8089495db>
(131)
Patch Links:
- https://github.com/AdaCore/ada-spark-rfcs/pull/38.patch
- https://github.com/AdaCore/ada-spark-rfcs/pull/38.diff
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#38?email_source=notifications&email_token=AANZ4FJ7ODSJ2BEPLJ54J6TRFFX3JA5CNFSM4K535R2KYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4IRHDLIQ>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AANZ4FMMPEHBCSK5TRVIB3DRFFX3JANCNFSM4K535R2A>
.
|
This is an initial proposal allowing to fix the lower bound of an array type, in an attempt at fixing some Ada-specific performance footprint.
Link to text: https://github.com/QuentinOchem/ada-spark-rfcs/blob/master/considered/rfc-lower-bound.rst