comp.lang.ada
 help / color / mirror / Atom feed
From: Robert A Duff <bobduff@shell01.TheWorld.com>
Subject: Re: Function definitions
Date: Fri, 20 Jun 2014 16:39:31 -0400
Date: 2014-06-20T16:39:31-04:00	[thread overview]
Message-ID: <wcc7g4bmi2k.fsf@shell01.TheWorld.com> (raw)
In-Reply-To: 7597c304-0dc2-41ad-b04e-1aef133e5b63@googlegroups.com

montgrimpulo <aghte@hotlinemail.com> writes:

> P,Q,R : Natural;
>
> 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.  P, Q, and R are not initialized yet.  Assigning into
them later won't suddenly change the lengths of those arrays.
I think you want a discriminated record, as in:

    type Individual(P, Q, R : Natural) is record ...

> This is in principle what I want to set up and run, while I want to be
> flexible in defining F and G and other parameters, without having to
> modify the files search.ads and search.adb.

So you want (for example) P1 to call different versions of F?  If so,
then you can pass F into P1:

    procedure P1(F: not null access function (...) return ...);

Then the body of P1 can call F:

    procedure P1(F: not null access function (...) return ...) is
        XYZ : ... := F(...);
    begin
        ...

When you call P1, you create a function My_F, and pass My_F'Access to
P1:

    P1(F => My_F'Access);

- Bob

  parent reply	other threads:[~2014-06-20 20:39 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
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 [this message]
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