Questions tagged [ada2012]

Ada 2012 is the current standard of the Ada programming language.

Ada 2012 is the current standard (as define by ISO/IEC 8652:2012) of the Ada programming language.

New in Ada 2012

Contract-based Programming

  • Preconditions and postconditions define the expectations and obligations of a subprogram.
  • Type invariants specify boundary constraints for objects of an encapsulated (private) type.
  • Subtype predicates capture general constraints on data objects.

Concurrency and Multicore Support

  • Task affinities and dispatching domains allow tasks to be mapped to specific CPUs or cores.
  • Ravenscar for multiprocessor systems adapts a safe and widely used tasking profile to modern architectures.

Increased Expressiveness

  • Expression functions offer a convenient way to express simple functions.
  • Conditional expressions provide a compact notation for a common idiom.
  • Quantified expressions for universal and existential forms specify predicates over arrays and containers.

Container Enhancements

  • Bounded containers use stack allocation and do not incur the overhead of dynamic memory management.
  • Task-safe queues and priority queues provide efficient implementations of synchronized structures.
  • Holder containers create singleton structures for objects of an unconstrained type.
  • Iterators provide familiar idioms with uniform syntax to search and manipulate arrays and containers.

See more

40 questions
12
votes
3 answers

Proving Floor_Log2 in Spark

New to Spark, and new to Ada, so this question may be overly broad. However, it's asked in good faith, as part of an attempt to understand Spark. Besides direct answers to the questions below, I welcome critique of style, workflow, etc. As my first…
6
votes
1 answer

How do you implement Generic_Sorting in Ada for a vector?

I'm trying to do some basic translations of old C++ code from many moons ago to learn Ada, and I have been absolutely stumped on how to sort a vector using the built-in Generic_Sorting. I haven't been able to find any concrete examples of it in…
ZSwat
  • 85
  • 6
5
votes
1 answer

In only ISO standard Ada, how can Record Representation Clause + any other language feature(s) be portable to little-endian and big-endian processors?

Without utilizing the nonstandard‡ Scalar_Storage_Order clause in recent releases of GNAT, how can, say, the IPv4 header be portably represented via Record Representation Clause(s) in conjunction with any combination of any other language features,…
Andreas ZUERCHER
  • 862
  • 1
  • 7
  • 20
4
votes
1 answer

Type conversions and if expressions

In this page, John Barnes writes: If the conditional expression is the argument of a type conversion then effectively the conversion is considered pushed down to the dependent expressions. Thus X := Float(if P then A else B); is equivalent to X :=…
Big Temp
  • 434
  • 4
  • 12
4
votes
2 answers

Passing struct/record from assembler to Ada

I'm attempting to pass a structure from (x86) assembler to Ada on the stack. I've been able to successfully use this pattern in C to accept to wrap a large number of arguments passed from assembly inside a struct and I'm wondering if this will work…
ajxs
  • 3,347
  • 2
  • 18
  • 33
4
votes
3 answers

SPARK Integer overflow check

I have the following program: procedure Main with SPARK_Mode is F : array (0 .. 10) of Integer := (0, 1, others => 0); begin for I in 2 .. F'Last loop F (I) := F (I - 1) + F (I - 2); end loop; end Main; If I run gnatprove, I get the…
rid
  • 61,078
  • 31
  • 152
  • 193
4
votes
2 answers

How to stop execution in my program

Without copy-pasting my code here, how can I stop my ADA program from executing anymore lines of code during run-time if it calculates a certain value to 'X'? something like: variable_name := variable_name +4; if variable_name >1 then // END…
user2855405
  • 495
  • 2
  • 7
  • 20
3
votes
1 answer

Prevent Ada 202x Use in GNAT

GNAT allows the following code due to Random(Generator, First, Last) being implemented in the runtime, but it's not part of Ada 2012. Can I cause this to generate a compile error since it shouldn't be available? with Ada.Text_IO; use…
pyj
  • 1,489
  • 11
  • 19
3
votes
2 answers

Return an array with one element in Ada

I'm trying to return an array which only has one element from a function. I've tried a few flavors and still can't find what it wants me to do: with Ada.Text_IO; use Ada.Text_IO; procedure Beer_Lists is type Beer is (Guinness, PBR,…
pyj
  • 1,489
  • 11
  • 19
3
votes
1 answer

Puzzling "info" message regarding package body requirement using Ada?

I am experiencing a peculiar "info" message from GNAT 7.4.0 (running on an "Ubuntu 19.04" system) while in the early stages of developing a QR-code generator. I'm using some fairly aggressive compilation switches: gnatmake -gnata -gnateE -gnateF…
user5069935
2
votes
2 answers

Idiomatic Way to Pass an Empty Enumeration to a Generic in Ada

I'm instantiating a generic package with an enumeration to access one of multiple values and use in subprogram overloading. I want to have a well-defined, compile-time checked set of values I can use and look up. generic -- Different types…
pyj
  • 1,489
  • 11
  • 19
2
votes
0 answers

How elements are stored within Hashmap in Ada?

I would like to know if the Element_Type object is stored within a Hashmap in Ada (either a normal Hashmap, indefinite or bounded) as is or it is only stored a pointer to the instance of the real Element_Type object, that is, I want to be sure that…
Albatros23
  • 297
  • 2
  • 14
2
votes
2 answers

Ada: What is the best way to promote Intermediate value in user defined operators on vectors?

Let me first provide some context in hope it will make the problem clearer: I am receiving byte vector data from Hardware which I wish to operate on. I do not wish to convert the date to larger size due to size and time constraints. I want to allow…
PolarBear2015
  • 745
  • 6
  • 14
2
votes
1 answer

Ada - Accessibility check raised within a procedure

I previously asked a question regarding accessibility checks being raised in Ada, which @Brian Drummond was kind enough to awnser. The accessibility check was in a function, now I have a similair problem within a procedure; any guidance as to why…
Lloyd Thomas
  • 345
  • 2
  • 12
2
votes
1 answer

Ada - accessibility check raised

I have downloaded this program from Github: https://github.com/raph-amiard/ada-synth-lib I have attemted the first example and I am presented with an exception. If anybody would be able to give me an insight into why this is, it would be massively…
Lloyd Thomas
  • 345
  • 2
  • 12
1
2 3