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=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.31.244.143 with SMTP id s137mr4771597vkh.23.1485018333476; Sat, 21 Jan 2017 09:05:33 -0800 (PST) X-Received: by 10.157.43.215 with SMTP id u81mr2013387ota.15.1485018333324; Sat, 21 Jan 2017 09:05:33 -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!2.eu.feeder.erje.net!feeder.erje.net!2.us.feeder.erje.net!newspeer1.nac.net!border2.nntp.dca1.giganews.com!nntp.giganews.com!i7no342337qta.1!news-out.google.com!78ni19846itm.0!nntp.google.com!r185no1195231ita.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Sat, 21 Jan 2017 09:05:33 -0800 (PST) In-Reply-To: <83409c51-59d3-4205-9eeb-5467de09f069@googlegroups.com> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=76.218.37.33; posting-account=W2gdXQoAAADxIuhBWhPFjUps3wUp4RhQ NNTP-Posting-Host: 76.218.37.33 References: <83409c51-59d3-4205-9eeb-5467de09f069@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <3b436d6a-7704-47cf-8f6f-d974771bea63@googlegroups.com> Subject: Re: Q: Trouble creating array and discriminated type From: Stephen Leake Injection-Date: Sat, 21 Jan 2017 17:05:33 +0000 Content-Type: text/plain; charset=UTF-8 Xref: news.eternal-september.org comp.lang.ada:33111 Date: 2017-01-21T09:05:33-08:00 List-Id: On Friday, January 20, 2017 at 4:55:52 PM UTC-6, b.mcgui...@gmail.com wrote: Addressing the second problem: > type Ephemeris_Data (Offset_Maximum, Record_Maximum : Positive) is tagged record If you add defaults to the discriminants, Ada will let you declare an uninitialized object. On the other hand, it might try to allocate all of memory for it, in which case the access object is a better solution. > JPL_Data : access JPL_Ephemeris.Ephemeris_Data; > > procedure initialize (header_file_pathname, coefficient_file_pathname : String) is > begin > Real_IO.Open (File, Real_IO.In_File, coefficient_file_pathname); > JPL_Data := JPL_Ephemeris.Make (header_file_pathname)'Access; This should be: JPL_Data := new JPL_Ephemeris.Ephemeris_Data'(JPL_Ephemeris.make (file); It might be better to not declare this object in the package, but rather in the subprogram where it is needed; then you could avoid the access type. On the other hand, if it is shared among many subprograms, this is the right way. -- Stephe