From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: * X-Spam-Status: No, score=1.3 required=5.0 tests=BAYES_00,INVALID_MSGID, MSGID_RANDY autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,c56a86f3a4e16d06 X-Google-Attributes: gid103376,public From: Robert Dewar Subject: Re: Containers with Ada Date: 2000/11/19 Message-ID: <8v8v3e$hqp$1@nnrp1.deja.com>#1/1 X-Deja-AN: 695433958 References: <8v8pii$dvo$1@nnrp1.deja.com> X-Http-Proxy: 1.0 x52.deja.com:80 (Squid/1.1.22) for client 205.232.38.240 Organization: Deja.com - Before you buy. X-Article-Creation-Date: Sun Nov 19 16:28:34 2000 GMT X-MyDeja-Info: XMYDJUIDrobert_dewar Newsgroups: comp.lang.ada X-Http-User-Agent: Mozilla/4.61 [en] (OS/2; I) Date: 2000-11-19T00:00:00+00:00 List-Id: 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.