comp.lang.ada
 help / color / mirror / Atom feed
From: mheaney@ni.net (Matthew Heaney)
Subject: Re: Passing arrays as record fields
Date: 1997/06/13
Date: 1997-06-13T00:00:00+00:00	[thread overview]
Message-ID: <mheaney-ya023680001306972025020001@news.ni.net> (raw)
In-Reply-To: 33A00D4C.F4E@taz.dra.hmg.gb


In article <33A00D4C.F4E@taz.dra.hmg.gb>, Mark J Gallagher
<mjgallagher@taz.dra.hmg.gb> wrote:


>  type Count_t is Integer range 0 .. Integer'Last;
>  type Count_a is array (Integer range <>) of Count_t;
>  type Net_t(... N_Neurons: Count_t ...) is record
>    ...
>    Neuron_Counts: Count_a(N_Neurons);
>    ...
>  end record;
>
>and a procedure
>
>  procedure Initialise(Net: in out Net_t);
>
>I can declare a variable Net of type Net_t and assign an array to the
>Neuron_Counts field, which I can read from the block in which Net has
>been declared. However, when I attempt to read the array from the
>procedure Initialise, I get garbage. Help!

A few points:

If you just need a "count" type, use the predefined type Natural.

Do you want you neural net type to be constrained or unconstrained?  That
is, should neural net objects be mutable or not?

Try this:

type Natural_Array is array (Positive range <>) of Natural;

subtype Neural_Net_Length_Range is 
   Natural range 0 .. 100;  -- or whatever max is appropriate

type Neural_Net (Length : Neural_Net_Length_Range := 0) is
   record
      Counts : Natural_Array (1 .. Length);
   end record;

I know nothing about neural nets, so you may need to do some more
explaining before I totally understand your problem.

What is the purpose of Initialize?  Does it set the count?  Or does it
merely read the count specified by the client?  The former means the neural
net type is mutable, the latter that mutability is optional.

And what I mean by mutability is, Is the subtype definate?  An indefinate
subtype (without a default value for the discriminant) would have to be
constrained by the client (unless of course the Initialize subprogram were
a function, in which case the subprogram could define the constraint).

Tell me more about what Initialize is trying to do, and be more specific
about the problems you're having.

--------------------------------------------------------------------
Matthew Heaney
Software Development Consultant
<mailto:matthew_heaney@acm.org>
(818) 985-1271




  reply	other threads:[~1997-06-13  0:00 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-06-12  0:00 Passing arrays as record fields Mark J Gallagher
1997-06-13  0:00 ` Matthew Heaney [this message]
1997-06-14  0:00   ` Robert Dewar
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox