Skip to content

[feature] Import Array from Address #169

@tonunaks

Description

@tonunaks

Summary

This proposal introduces the possibility of dynamically creating an access to
and Ada unconstrained array from an address and its boundaries.

Motivation

It is difficult today to create access to arrays created from outside of Ada,
e.g. when coming from C, as there's no way to dynamically create their
boundaries. This proposal will make it possible and simplify interfacing
between system data and other languages.

Caveats and alternatives

This introduces a new "unsafe" construction in Ada, although it is well identified
and easy to track/forbid.

This also adds more constraints on the implementation. Some compilers implement
access to arrays in a way that generates two pointers, one to the data and
another to the bounds, which can then be put in the same place when allocating
memory for Ada. The issue then becomes the free operation - if all memory is
allocated from Ada, it is possible to free both the data and the boundaries at
the same time. However, in the example here, the address is externally provided
and is not necessarily expected to be freed from the Ada side. An alternate
implementation, such as putting the boundaries of the object in the pointer as
opposed to indirectly referring to it, does fix this problem, but requires in-depth
changes. Note that this is also necessary for other RFCs (such as access to array
slice).

Metadata

Metadata

Assignees

No one assigned

    Labels

    STAT::proposedA proposal from the initiator, waiting for go-aheadenhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions