Tutorial by Examples

Generic subprograms are usefull to create a subprograms that have the same structure for several types. For example, to swap two objects: generic type A_Type is private; procedure Swap (Left, Right : in out A_Type) is Temp : A_Type := Left; begin Left := Right; Right := Temp; ...
In Ada generic package, upon instantiation, data are duplicated; that is, if they contain global variables, each instance will have its own copy of the variable, properly typed and independent from the others. generic type T is private; package Gen is type C is tagged record V :...
Ada offers a wide variety of generic parameters which is difficult to translate into other languages. The parameters used during instantiation and as a consequence those on which the generic unit may rely on may be variables, types, subprograms, or package instances, with certain properties. For exa...

Page 1 of 1