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,75ffc1f081ec10e3 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!wns14feed!worldnet.att.net!attbi_s21.POSTED!53ab2750!not-for-mail From: "Jeffrey R. Carter" Organization: jrcarter at acm dot org User-Agent: Thunderbird 1.5 (Windows/20051201) MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Constant record components References: <12ad8guf3sg1o0d@corp.supernews.com> <1loq7utmaxvll$.yqsxj5edzqgv.dlg@40tude.net> <12adcn2kslq7d80@corp.supernews.com> <1151778788.25270.4.camel@localhost.localdomain> In-Reply-To: <1151778788.25270.4.camel@localhost.localdomain> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Message-ID: NNTP-Posting-Host: 12.201.97.176 X-Complaints-To: abuse@mchsi.com X-Trace: attbi_s21 1151790249 12.201.97.176 (Sat, 01 Jul 2006 21:44:09 GMT) NNTP-Posting-Date: Sat, 01 Jul 2006 21:44:09 GMT Date: Sat, 01 Jul 2006 21:44:09 GMT Xref: g2news2.google.com comp.lang.ada:5399 Date: 2006-07-01T21:44:09+00:00 List-Id: Georg Bauhaus wrote: > On Sat, 2006-07-01 at 10:37 -0700, ME wrote: > >> What I meant was components that can not be changed after the record >> components are initialized. > > package rec is > type R is tagged private; > > function make(m: INTEGER) return R; > -- `m` is the initial value for the immutable component > > function immutable(thing: R) return INTEGER; > private ... > end rec; A : Rec.R := Rec.Make (1); Y : Integer; X : constant Integer := Rec.Immutable (A); begin A := Rec.Make (2); Y := Rec.Immutable (A); if X = Y then Ada.Text_IO.Put_Line ("Component is constant"); else Ada.Text_IO.Put_Line ("Component is not constant"); end if; You get 3 guesses which string is output, and the 1st 2 don't count. Clearly, this does not meet the OP's interest in components that cannot be changed after initialization. -- Jeff Carter "When danger reared its ugly head, he bravely turned his tail and fled." Monty Python and the Holy Grail 60