Please disable your adblock and script blockers to view this page

Going beyond Ada 2022

Ada 2022
the Ada Rapporteur Group
GNAT Community
GNAT Pro 22 Continuous Release

GNAT CE 2021
Product Engineering
GNAT Programming Studio


Arnaud Charlet

No matching tags

No matching tags

GNAT Community


No matching tags

Positivity     36.00%   
   Negativity   64.00%
The New York Times
Write a review: Hacker News

The peculiar object model in Ada turned out to be a contentious issue, with some strong supporters and strong opponents, who advocated for rebuilding it more alike to the dominant model of Java/C++.Thanks to the suggestions received so far from both external contributors and from the language design team at AdaCore, we have started adding some of these new experimental features, with a first implementation available in the latest GNAT Community 2021 release as well as the latest GNAT Pro 22 Continuous Release, under the -gnatX switch and detailed below.Let's first start with two "most wanted" features that many Ada users have been asking for years:Detailed in RFC#38, you can now specify a lower bound for unconstrained arrays that is fixed to a certain value.Use of this feature increases safety by simplifying code, and can also improve the efficiency of indexing operations.For example, a matrix type with fixed lower bounds of zero for each dimension can be declared by the following:Objects of type Matrix declared with an index constraint must have index ranges starting at zero:Similarly, a subtype of String can be declared that specifies the lower bound of objects of that subtype to be 1:If a string slice is passed to a formal of subtype String_1 in a call to a subprogram S, the slice’s bounds will “slide” so that the lower bound is 1. It provides an extension of case statements to cover records and arrays, as well as finer grained casing on scalar types and will in particular in the future provide more compile time guarantees when accessing discriminated fields.For example, you can match on several scalar values:Matching composite types is currently only supported on records with no discriminants. Do_This will be called; otherwise, if either component is nonnegative (Natural) then Do_That will be called; otherwise, Do_The_Other_Thing will be called.If the set of values that match the choice(s) of an earlier alternative So by introducing a new restrictions pragma, we want to both simplify the rules and propose a model where runtime accessibility checks related to the use of anonymous access types are suppressed and replaced by compile time checks, in particular because the runtime accessibility checks are either impossible to implement fully, or worse, may produce false alarms (raising an exception in cases where no dangling access is actually occurring).So if you add as part of your configuration pragmas the following:This will enable this new mode. Currently two variants are implemented:The default model when using No_Dynamic_Accessibility_Checks in GNAT Community Edition 2021 although in the more recent GNAT Pro development version, we've switched this model with the other one and this one will be enabled via the -gnatd_b debug switch, in addition to the restriction.In this model, anonymous access types are implicitly declared at the point where the designated type is declared.Available via the additional use of the -gnatd_b switch in GNAT CE 2021 and by default when using No_Dynamic_Accessibility_Checks in more recent GNAT Pro versions, the anonymous access types are implicitly declared at the point where the anonymous access is used (as part of a subprogram parameter, object declaration, etc...).Both models may be refined further based on the feedback received on actual code and what users would find most useful and practical, so do not hesitate to give it a try and let us know!Do you find some of these features useful?

As said here by