Mega Search
23.2 Million


Sign Up

Make a donation  
Curiosity in generic package instantiation  
News Group: comp.lang.ada

Hi all,

pardon if using not the exact terminology (too old to learn ADA intricacies, 
whish had done it back in the '80-'90 when I was active programmer, but then 
in Italy buzzword was c/c++ m$oft version, and VB), I noticed the following 
excerpt in a previous thread:

....
procedure Test_List is
    type Example_Type is record
      A :Integer := 0;
      B: Integer := 0;
    end record;

....

  declare
    Data : Example_Type;
    package Example_Pkg is new
Ada.Containers.Doubly_Linked_Lists(Example_Type);
    List : Example_Pkg.List;

if I understand well, this means that the Ada.Containers.Doubly_Linked_Lists 
package is instantiated using Example_Type, and the instantiated list name 
is Example_Pkg.List.

Is this done by text substitution at source/intermediate code level 
(something like the C preprocessor), albeit in an user-transparent (=better) 
way, or is it obtained by some property of the list elements, able to store 
whatever is thrown at them, even elements of different type in the same 
list?

My 1st guess looking at the code is sort of compiler-integrated 
preprocessing.

Just curious.

Thanks in advance.

Gigi

Vote for best question.
Score: 0  # Vote:  0
Date Posted: 20-Aug-2014, at 12:26 AM EST
From: GianLuigi Piacentini