Returning a function in Ada

Is it possible, that a function can return a function in Ada? I am trying to get currying to work. type Integer_Func_Type is access function (Y : Integer) return Integer; function Add (X : Integer) return Integer_Func_Type is function Inner (Y :...
more »

2017-08-21 22:08 (3) Answers

Ada Generic Formal Subprograms

I'm doing an Ada assignment for school. My teacher has provided me with the following code. This is for a generic tree. generic type Item_Type is private; with procedure put(i : Item_Type); I create a new generic tree in my test file, as s...
more »

2017-04-30 02:04 (2) Answers

Ada Generic Package Extension

I have a generic package Containers.Stacks which looks roughly like generic type Value_Type is private; package Containers.Stacks with Preelaborate is --Node stuff type Stack is new Container with private; --Other Stack stuff ...
more »

2017-03-12 11:03 (3) Answers

Ada container in a Extended tagged type

I want to had a container in an extended tagged type. Ex. : type Root is abstract tagged private; package Queue_Interface is new Ada.Containers.Synchronized_Queue_Interfaces (Element_Type => Ada.Strings.Unbounded.Unbounded_String); package Qu...
more »

2017-02-11 23:02 (3) Answers

Ada: How to write overload for "or" operator?

I have been told that Ada supports "or" between boolean values. My goal is to be able to write an overload for this function using generics that supports integer types 0 and 1. (I know I can add them to get return value: if sum >= 1, return 1, else r...
more »

2017-02-05 21:02 (0) Answers

Ada Generics: Stack vs Heap Clarification

So I have an assignment that says: Please use generic instantiations of packages/classes. Space for each BMR (matrix) must be allocated in the system stack within the generic package/template, probably during generic instantiation! You specificall...
more »

2017-02-05 08:02 (1) Answers

How to print a generic type in ada?

i am currently trying to print ("Ada.Text_IO.Put") a generic type, but this always fails with errors like that: missing argument for parameter "Item" in call to "Put" declared at, instance at expected type "Standard.I...
more »

2017-01-06 23:01 (2) Answers

Ada OOP "generic" types for abstract type

What I want to do is make a type that, among other things, controls values that other parts of the code pass to it. This is part of a menu system, and would extend an abstract type and itself be abstract. What I would like to do is store an access. S...
more »

2016-12-02 14:12 (1) Answers

In Ada generic packages

In Ada Generic packages if I have a package that deals with any element you put in, if I would want to demonstrate that the package is working, would I have to run two separate client programs to show Integer and then Float, or could I do all that in...
more »

2016-11-14 23:11 (1) Answers

How to get this generic package to compile

I have the program to where it is reading the generic package, but I cannot figure out what to do about the context clauses to get the numbers to print and/or be read in from the file. In the client program right now, I have that the Element_Type sho...
more »

2016-11-14 18:11 (2) Answers

Ada sending byte buffer to c

I'm having an issue with interfacing to C from ada. In particular I have this ada declaration: type Byte is mod 256; pragma Convention (C, Byte); type ByteStream is array (Interfaces.C.size_t range <>) of Byte; pragma Convention (C, ByteSt...
more »

2016-10-17 18:10 (2) Answers

How to force accurate indices on a private type

I have a private type that internally uses a 2 dimensional array, while doing additional processing whenever the elements of that array are set. My package looks something like this: with MyElements; generic Width, Height : Positive; package MyP...
more »

2016-09-30 17:09 (1) Answers