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=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,5117b1b6391a0e06 X-Google-Attributes: gid103376,public Path: g2news1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!newsfeed.vmunix.org!newsfeed01.sul.t-online.de!newsmm00.sul.t-online.de!t-online.de!news.t-online.com!not-for-mail From: Martin Krischik Newsgroups: comp.lang.ada Subject: Re: A simple ADA puzzle (I haven't the answer) Date: Wed, 16 Jun 2004 18:49:54 +0200 Organization: AdaCL Message-ID: <4156573.X2A1sUPmHW@linux1.krischik.com> References: Reply-To: krischik@users.sourceforge.net Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7Bit X-Trace: news.t-online.com 1087404611 05 9856 7zySXvn6QrZuy6t 040616 16:50:11 X-Complaints-To: usenet-abuse@t-online.de X-ID: r6y8wrZUYe02Ua9TQ-TmXV5hRqaICMXvBk+uNBYVdGkUhMiQEzXeEq User-Agent: KNode/0.7.7 Xref: g2news1.google.com comp.lang.ada:1578 Date: 2004-06-16T18:49:54+02:00 List-Id: Abby wrote: > Hi! I have this code: > > type LEN_TYPE is array (INTEGER range <>) > of CHARACTER; > > type STRING_TYPE (LEN : INTEGER := 0) is > record > STRING : LEN_TYPE (1 .. LEN); > end record; STRING_TYPE'Size = (2**32 * 8 + 32); > type UNC2_ARRAY_TYPE is array (INTEGER range <>) > of STRING_TYPE; > > type RET2_TYPE (INIT : INTEGER := 0) is > record > IFOS : UNC2_ARRAY_TYPE (1 .. INIT); > end record; RET2_TYPE'Size = ((2**32 * 8 +32) * (2**32 * 8)) +32; > type RET_TYPE > ( DEF : INTEGER := 0 ) > is > record > ID : INTEGER; > IFO : RET2_TYPE (INIT => DEF); > end record; RET_TYPE'Size = ((2**32 * 8 +32) * (2**32 * 8)) +32 + 2 * 32 > type UNC_ARRAY_TYPE is > array (INTEGER range <>) of > RET_TYPE; > > and i'd like to initialize and use a variable of type UNC_ARRAY_TYPE (for > the unconstraint array and records choose any value you want, al least 1 > :) ). I can say that simply write VAR : UNC_ARRAY_TYPE (1..3); gives > :some > warning but compiles, but gives also a beautiful constraint_error when you > use it, obviously. Any ideas? Thanx for your time! Normalise to byte: RET_TYPE'Storage_Elements = ((2**32 +4 ) * (2**32)) +4 + 2 *4 RET_TYPE'Storage_Elements = ((2**32 +4 ) * (2**32)) +12 RET_TYPE'Storage_Elements = 18.446.744.090.889.420.812 So unless you have 17.179.869.200 GB to spare the program is going to fail. Try something like: type Max_Len is range 0 .. 255; type LEN_TYPE is array (Max_Len range <>) But this will still be a static solution which will wast lots of memory Maybe using Ada.Unbounded_Strings it the better option. And some component library with some form of dynamic Array. There are lots of the around. With Regards Martin With Regards Martin -- mailto://krischik@users.sourceforge.net http://www.ada.krischik.com