From: Shark8 <OneWingedShark@gmail.com>
Subject: Re: Function definitions
Date: Sun, 22 Jun 2014 00:59:59 -0600
Date: 2014-06-22T00:59:59-06:00 [thread overview]
Message-ID: <S9vpv.35629$LR3.20311@fx28.iad> (raw)
In-Reply-To: <5a8316fb-9b3d-405b-8199-edcaf18dcaa6@googlegroups.com>
On 20-Jun-14 10:22, montgrimpulo wrote:
> My modified question:
>
> Hi,
> What would be an answer to the following question:
> There are three files : search.ads, search.adb, main_search.adb.
>
> In search.ads two functions are defined: function F and function G, as
>
> function F (V : Individual) return Long_Float; and
>
> function G(M : Natural; V : Individual) return Long_Float;
>
> Individual is defined as a Record containing several arrays
> with a size determined by variables, eg .
>
> type Individual is record
> X : x_array (0 .. P);
> Y : y_array (0 .. Q);
> Z : z_array (0 .. R);
> end record;
That won't work as-is because arrays within records cannot be unconstrained.
You could make the package generic and use formal parameters though:
Generic
P, Q, R : in Natural:= 0;
Package Search is
type Individual is record
X : x_array (0 .. P);
Y : y_array (0 .. Q);
Z : z_array (0 .. R);
end record;
function F (V : Individual) return Long_Float;
function G (M : Natural; V : Individual) return Long_Float;
End Search;
--OR
You could use discriminants:
type Individual(P,Q,R : Positive:= 1) is record
X : x_array (0 .. P);
Y : y_array (0 .. Q);
Z : z_array (0 .. R);
end record;
next prev parent reply other threads:[~2014-06-22 6:59 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-20 15:18 Function definitions montgrimpulo
2014-06-20 15:44 ` Adam Beneschan
2014-06-20 16:22 ` montgrimpulo
2014-06-20 16:43 ` Adam Beneschan
2014-06-20 16:52 ` Simon Clubley
2014-06-20 17:05 ` Adam Beneschan
2014-06-20 16:43 ` Simon Clubley
2014-06-22 6:59 ` Shark8 [this message]
2014-06-20 17:39 ` montgrimpulo
2014-06-20 18:19 ` Adam Beneschan
2014-06-20 18:20 ` Adam Beneschan
2014-06-21 20:56 ` Stephen Leake
2014-06-22 12:27 ` Simon Clubley
2014-06-20 20:39 ` Robert A Duff
2014-06-21 12:27 ` montgrimpulo
2014-06-21 12:38 ` Simon Clubley
2014-06-21 17:57 ` Jeffrey Carter
2014-06-21 13:40 ` montgrimpulo
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox