comp.lang.ada
 help / color / mirror / Atom feed
From: Robert Dewar <robert_dewar@my-deja.com>
Subject: Re: Containers with Ada
Date: 2000/11/19
Date: 2000-11-19T00:00:00+00:00	[thread overview]
Message-ID: <8v8v3e$hqp$1@nnrp1.deja.com> (raw)
In-Reply-To: 8v8pii$dvo$1@nnrp1.deja.com

In article <8v8pii$dvo$1@nnrp1.deja.com>,
  jeltsch@my-deja.com wrote:
>    3. High memory consumption with unconstrained arrays
>    An easy way to define a type for lists with fixed length
> would be for
>    instance
>       type Element_Array is array(Positive range <>) of
>                                                    Element;
>       type List(Length : Natural) is record
>          Elements : Element_Array(1 .. Length);
>       end record;
>    With this implementation one could even think of making the
> whole type
>    definition public. But one cannot expect that a compiler
> will generate code
>    that dynamically allocates memory that is just enough for
> Elements. As I
>    can see GNAT doesn't operate with implicit pointers to
> dynamically
>    allocated memory but sets the size of List so that it is
> big enough for
>    every value for Length.

Nope, that's completely wrong. When there are no default
discriminants, the language requires that only the necessary
storage for the particular value be allocated, and that's
how GNAT is working. Most likely you are confused about the
role of default discriminants (although the example you gave
does not contain any). The use of default discriminants has
profound affects on the way storage is allocated.

I would suggest posting complete small examples and asking
direct questions about these examples. When you post large
brush statements based on incorrect assumptions, it is hard
to know where to start to help!


Sent via Deja.com http://www.deja.com/
Before you buy.




  parent reply	other threads:[~2000-11-19  0:00 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-11-19  0:00 Containers with Ada jeltsch
2000-11-19  0:00 ` Robert Dewar
2000-11-20  4:37   ` Brian Rogoff
2000-11-20  0:00     ` Ted Dennison
2000-11-20  0:00       ` Brian Rogoff
2000-11-19  0:00 ` Robert Dewar
2000-11-20  0:00   ` Wolfgang Jeltsch
2000-11-19  0:00 ` Robert Dewar [this message]
2000-11-19  0:00 ` Ken Garlington
2000-11-20  0:00   ` Wolfgang Jeltsch
2000-11-20  0:00   ` Wolfgang Jeltsch
2000-11-19  0:00 ` Robert Dewar
2000-11-20  0:00 ` Marc A. Criley
2000-11-20  0:00   ` Brian Rogoff
2000-11-20  0:00     ` Stephen Leake
2000-11-20  0:00       ` Brian Rogoff
2000-11-21  0:00       ` Marc A. Criley
2000-11-21  0:00       ` Warren W. Gay VE3WWG
2000-11-21  0:00         ` Stephen Leake
2000-11-21  0:00           ` Warren W. Gay VE3WWG
2000-11-21  0:00             ` Stephen Leake
2000-11-22  0:00               ` Containers with Ada (distribution of) Warren W. Gay VE3WWG
     [not found]                 ` <004d01c0567b$cd4e49c0$b0375140@Fudge>
2000-11-25  0:00                   ` Does anyone use Anna? Lao Xiao Hai
2000-11-22  0:00               ` Containers with Ada Warren W. Gay VE3WWG
2000-11-20  0:00   ` Wolfgang Jeltsch
replies disabled

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