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!news3.google.com!newshub.sdsu.edu!logbridge.uoregon.edu!newsfeeds.ihug.co.nz!lust.ihug.co.nz!ihug.co.nz!not-for-mail From: Craig Carey Newsgroups: comp.lang.ada Subject: Re: Constant record components Date: Sat, 15 Jul 2006 00:51:18 +1200 Organization: Ihug Ltd Message-ID: References: <12afs64kh432q0e@corp.supernews.com> <12aihj2lrjqpc3a@corp.supernews.com> <7bednaJHX_FTMDTZnZ2dnUVZ_uudnZ2d@megapath.net> <12ak5urrrj6d756@corp.supernews.com> <12arsrtbe8flpf8@corp.supernews.com> NNTP-Posting-Host: 203.118.188.194 Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: lust.ihug.co.nz 1152881383 17384 203.118.188.194 (14 Jul 2006 12:49:43 GMT) X-Complaints-To: abuse@ihug.co.nz NNTP-Posting-Date: Fri, 14 Jul 2006 12:49:43 +0000 (UTC) X-Newsreader: Forte Agent 3.1/32.783 Xref: g2news2.google.com comp.lang.ada:5688 Date: 2006-07-15T00:51:18+12:00 List-Id: Fixing renames. On Fri, 14 Jul 2006 20:15:53 +1200, Craig Carey wrote: >On Fri, 7 Jul 2006 16:04:13 -0500, "Randy Brukardt" wrote: ... >>with them (only directly when the object is created), or you have to have >>some rule like "they're read-write in the body", which is what is >>disgusting. And remember that Initialize isn't the only routine of this ... A mispelling got partly towards converting jersey into jess, a leather strap sometimes attached to the leg of a hawk or falcon. At last check, Ada was not really making any progress at interfacing with C++, eg. in the following R.R would be written. generic Debug : Integer; package R is type R'Pkg_Type; -- Prevent an extra pass or "class package" etc. -- R could be a subtype if tagged for interfacing with C++. type R'Pkg_Type (D : DT) is record A1 : Integer; A2 : in Integer; end record; -- "in" means that in the view of exterior code the value -- can't be written to procedure Get_Val (X : out R, Fname : Str); end package R X : R (Dbg => 0) (D => D1); procedure Main is begin Get_Val (\ X, Fname => "abc.txt"); X.A2 := 9; -- Syntax error. The Ada Reference Manual does not use enough words to say what "renames" should do. GNAT tries to know the memory addresses finalized inside of the declaration block. When often encountering the mistake, it seems that a K : Integer := 1; while K < 10 loop declare A : Integer; K : constant; -- Lock K down as a constant E : Element renames A (K); -- Now it is clear E's address is now known begin -- K is constant -- Actually making K constant after the begin would be safer Craig Carey