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.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,8a34575d5eb275cb X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!postnews.google.com!q30g2000prq.googlegroups.com!not-for-mail From: Adam Beneschan Newsgroups: comp.lang.ada Subject: Re: Load an object from a file Date: Fri, 3 Apr 2009 09:46:02 -0700 (PDT) Organization: http://groups.google.com Message-ID: References: <49d5fa88$0$2862$ba620e4c@news.skynet.be> <443d72ca-5bbd-46a3-84c6-e8bd984e5b80@k41g2000yqh.googlegroups.com> <49d628f5$0$2865$ba620e4c@news.skynet.be> <49d6346e$0$32681$9b4e6d93@newsspool2.arcor-online.net> NNTP-Posting-Host: 66.126.103.122 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: posting.google.com 1238777162 15662 127.0.0.1 (3 Apr 2009 16:46:02 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Fri, 3 Apr 2009 16:46:02 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: q30g2000prq.googlegroups.com; posting-host=66.126.103.122; posting-account=duW0ogkAAABjRdnxgLGXDfna0Gc6XqmQ User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.7.12) Gecko/20050922 Fedora/1.7.12-1.3.1,gzip(gfe),gzip(gfe) Xref: g2news2.google.com comp.lang.ada:5397 Date: 2009-04-03T09:46:02-07:00 List-Id: On Apr 3, 9:08 am, Georg Bauhaus wrote: > Olivier Scalbert schrieb: > > > Thanks Ludovic, > > > One more question: > > > with: > > type u2 is new Integer; > > type cp_info is new Integer; > > > type Constant_Pool_Array is array (Positive range <>) of cp_info; > > type Interfaces_Array is array (Positive range <>) of u2; > > Make the index type the same as the type in the disciminant, > that is, u2. > > type Constant_Pool_Array is array (u2 range <>) of cp_info; > type Interfaces_Array is array (u2 range <>) of u2; > > since U2 is the type of the discriminants used in providing > the array bounds. Or, if you want to keep the "Positive" aspect: subtype Positive_U2 is U2 range 1 .. U2'Last; type Constant_Pool_Array is array (Positive_U2 range <>) of cp_info; type Interfaces_Array is array (Positive_U2 range <>) of U2; P.S. You may need to be a bit cautious if you define U2 as a modular type, as Ludovic suggested, and then use it as the base type of an unconstrained array. If you define type Some_Array is array (u2 range <>) of u2; you might be tempted to write code like this: procedure Do_Some_Operation (Count : U2) is Result : Some_Array (0 .. Count - 1); ... If you call Do_Some_Operation(0), Result is not going to be an empty array like you expect, but rather an array too large to fit in your computer, because 0-1 doesn't return a negative number for modular types but rather a very large positive number. -- Adam