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,55a8252137b5ef97 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news4.google.com!newsfeed.stanford.edu!cyclone.bc.net!newsfeed.telusplanet.net!newsfeed.telus.net!atl-c02.usenetserver.com!news.usenetserver.com!peer01.cox.net!cox.net!peer-uk.news.demon.net!kibo.news.demon.net!news.demon.co.uk!demon!not-for-mail From: "Luke A. Guest" Newsgroups: comp.lang.ada Subject: Re: Efficiently setting up large quantities of constant data Date: Mon, 13 Dec 2004 22:15:43 +0000 Message-ID: References: NNTP-Posting-Host: abyss2.demon.co.uk Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: news.demon.co.uk 1102976143 27822 62.49.62.197 (13 Dec 2004 22:15:43 GMT) X-Complaints-To: abuse@demon.net NNTP-Posting-Date: Mon, 13 Dec 2004 22:15:43 +0000 (UTC) User-Agent: Pan/0.14.2 (This is not a psychotic episode. It's a cleansing moment of clarity.) Xref: g2news1.google.com comp.lang.ada:6925 Date: 2004-12-13T22:15:43+00:00 List-Id: On Mon, 13 Dec 2004 13:48:49 -0800, Michael Mounteney wrote: > type structure is > record > part : component_ref; > end record; > > So I will have lots of structures scattered about, which will be > completely constant. I would like to enforce this constancy, but Ada Well, firstly, it seems like overkill to have a record which has only a pointer to an array. Surely, just creating your variables *as* instances of these arrays would be better? > (as far as I know) does not (unlike C++; that should get some hackles > rising) allow `constant' to be splashed about in type definitions. This > is on GNAT, which does not support pragma read_only. By doing the above, you can of course do the following: part : constant component_list := (...); -- Initialise me here!! > Is there any way to ensure that these data are not modified, other than > by forbidding direct access to structure.part etc? Do this with a package that *has memory* and it should work nicely. Also, make it private if you want and add an accessor that can only read from the arrays. Luke.