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,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.129.178.65 with SMTP id q62mr5435975ywh.122.1485061956500; Sat, 21 Jan 2017 21:12:36 -0800 (PST) X-Received: by 10.157.39.202 with SMTP id c68mr702117otb.8.1485061956455; Sat, 21 Jan 2017 21:12:36 -0800 (PST) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!1.eu.feeder.erje.net!feeder.erje.net!2.us.feeder.erje.net!feeder.usenetexpress.com!feeder1.iad1.usenetexpress.com!216.166.98.84.MISMATCH!border1.nntp.dca1.giganews.com!nntp.giganews.com!i7no421938qta.1!news-out.google.com!78ni22518itm.0!nntp.google.com!r185no1322361ita.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Sat, 21 Jan 2017 21:12:36 -0800 (PST) In-Reply-To: <3b436d6a-7704-47cf-8f6f-d974771bea63@googlegroups.com> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=2601:191:8303:2100:5985:2c17:9409:aa9c; posting-account=fdRd8woAAADTIlxCu9FgvDrUK4wPzvy3 NNTP-Posting-Host: 2601:191:8303:2100:5985:2c17:9409:aa9c References: <83409c51-59d3-4205-9eeb-5467de09f069@googlegroups.com> <3b436d6a-7704-47cf-8f6f-d974771bea63@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: Q: Trouble creating array and discriminated type From: Robert Eachus Injection-Date: Sun, 22 Jan 2017 05:12:36 +0000 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Xref: news.eternal-september.org comp.lang.ada:33114 Date: 2017-01-21T21:12:36-08:00 List-Id: On Saturday, January 21, 2017 at 12:05:34 PM UTC-5, Stephen Leake wrote: > On Friday, January 20, 2017 at 4:55:52 PM UTC-6, b.mcgui...@gmail.com wro= te: >=20 > Addressing the second problem: >=20 > > type Ephemeris_Data (Offset_Maximum, Record_Maximum : Positive) is ta= gged record >=20 > If you add defaults to the discriminants, Ada will let you declare an=20 > uninitialized object. On the other hand, it might try to allocate all of= =20 > memory for it, in which case the access object is a better solution. Since you are trying to learn Ada, it is worth noting that you can declare = subtypes for the index ranges, since you seem to have maximums that are set= when you run the program: subtype Offset is Positive range 1..Offset_Maximum; subtype Record_type is Positive range 1..Record_Maximum; -- or you can have one subtype if the bounds are the same... type Ephemeris_Data (Offset :=3D Offset_Maximum, Record_type :=3D Record_M= aximum) is tagged record... Now even if the compiler allocates the maximum size for each object, that'= s likely to be fine with you. Note that there is no requirement in Ada for= the values Offset_Maximum and Record_Maximum to be static. You can read t= hem in or get them from the keyboard, and no one will complain. One other "learning" type point. I always used to teach students that if t= hey needed something that eventually made sense as a standalone package, ne= st it within the main program until you get it running, then move toward gr= eater abstraction. In this particular case, your complaints about package = initialization seem to indicate that the package want to create should actu= ally be a generic package, instantiated inside the main program in a nested= scope. I don't really expect you to understand what I just said, until yo= u actually have a working program and transform it to have a separately com= piled generic package. ;-)