Skip to content

Commit 7970005

Browse files
committed
Minor wording updates to rfc-import-array-from-address.md
1 parent 415f663 commit 7970005

File tree

1 file changed

+24
-24
lines changed

1 file changed

+24
-24
lines changed

features/rfc-import-array-from-address.md

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
- Feature Name: Import Array from Address
22
- Start Date: 2025-05-06
3-
- RFC PR: (leave this empty)
4-
- RFC Issue: (leave this empty)
3+
- Status: Proposed
54

65
Summary
76
=======
@@ -34,9 +33,9 @@ For example:
3433
V : Arr_Access := Arr_Access'Address_To_Access (Create_C_Array_Of_Int (10), 1, 10);
3534
```
3635

37-
This attribute is available for all arrays. Constrained array do not require
36+
This attribute is available for all arrays. Constrained arrays do not require
3837
boundaries to be provided. Multi-dimenstional arrays will need dimensions to
39-
be provided in order, and fixed lower bound only require one dimension. For
38+
be provided in order, and fixed lower bound only requires one dimension. For
4039
example:
4140

4241
```ada
@@ -62,8 +61,8 @@ example:
6261
(Create_C_Array_Of_Int (10), 10);
6362
```
6463

65-
Attribute parameters are named either First, Last (for the one dimension case)
66-
or First_n, Last_n (for the n dimensions case).
64+
Attribute parameters are named either First, Last (in case of one dimension)
65+
or First_n, Last_n (in case of n dimensions).
6766

6867
Reference-level explanation
6968
===========================
@@ -76,11 +75,11 @@ Rationale and alternatives
7675

7776
The attribute could have been provided on arrays, and return an anonymous
7877
access type instead. To some respect, not presuming the type of the object
79-
and not requiring the creation of an explicit access type might be better.
80-
However, this brings all accessibility issues that don't really make sense
81-
when addressing external memory, and it's most likely that these will need
82-
to be converted away anyway. Note that is accessibilty is an issue, it's still
83-
possible instead to create a local array mapped to an address:
78+
and not requiring the creation of an explicit access type, might be better.
79+
However, this requires performing all accessinility checks that don't really
80+
make sense when addressing external memory. It's most likely that these checks
81+
will need to be disabled anyway. Note that if accessibilty checks are required,
82+
it is still possible to create a local array mapped to an address instead:
8483

8584
```ada
8685
type Arr is array (Integer range <>) of Integer;
@@ -95,19 +94,20 @@ possible instead to create a local array mapped to an address:
9594
Drawbacks
9695
=========
9796

98-
This introduces a new "unsafe" construction in Ada, although well identify and
99-
easy to track / forbids.
100-
101-
This also adds more constraints on implementation. Some compilers implement
102-
access to arrays in a way that generates two pointers, one to data and one
103-
to bounds - which can then put at the same place when allocating for Ada. The
104-
issue then becomes the free operation - if all is allocated from Ada, it's
105-
possible to free both the data and the boundaries at the same time. However,
106-
in the example here, the address is externally provided and is not necessarily
107-
expected to be freed from the Ada side. Alternate implementation, such as
108-
putting the boundaries of the object in the pointer as opposed to indirectly
109-
refering to it, does fix this problem but requires in depth changes. Note that
110-
this is also necessary for other RFCs (such as access to array slice).
97+
This introduces a new "unsafe" construction in Ada, although it is well identified
98+
and easy to track/forbid.
99+
100+
This also adds more constraints on the implementation. Some compilers implement
101+
access to arrays in a way that generates two pointers, one to the data and
102+
another to the bounds, which can then be put in the same place when allocating
103+
memory for Ada. The issue then becomes the free operation - if all memory is
104+
allocated from Ada, it is possible to free both the data and the boundaries at
105+
the same time. However, in the example here, the address is externally provided
106+
and is not necessarily expected to be freed from the Ada side. An alternate
107+
implementation, such as putting the boundaries of the object in the pointer as
108+
opposed to indirectly referring to it, does fix this problem, but requires in-depth
109+
changes. Note that this is also necessary for other RFCs (such as access to array
110+
slice).
111111

112112
Prior art
113113
=========

0 commit comments

Comments
 (0)