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,b30ef5c12f872cb8 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.68.0.170 with SMTP id 10mr11013821pbf.2.1322216602831; Fri, 25 Nov 2011 02:23:22 -0800 (PST) Path: lh20ni16089pbb.0!nntp.google.com!news1.google.com!postnews.google.com!e2g2000vbb.googlegroups.com!not-for-mail From: Ludovic Brenta Newsgroups: comp.lang.ada Subject: Re: Why constant components are not permitted ? Date: Fri, 25 Nov 2011 02:23:22 -0800 (PST) Organization: http://groups.google.com Message-ID: <16f6610a-39e3-4988-a239-eb7c1778ade8@e2g2000vbb.googlegroups.com> References: <1856c00b-1994-406a-bbb3-73d93785099a@i6g2000vbe.googlegroups.com> <87lir5tibe.fsf@ludovic-brenta.org> <1paloim06wnwx.1stqgrcrax4md.dlg@40tude.net> NNTP-Posting-Host: 153.98.68.197 Mime-Version: 1.0 X-Trace: posting.google.com 1322216602 12477 127.0.0.1 (25 Nov 2011 10:23:22 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Fri, 25 Nov 2011 10:23:22 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: e2g2000vbb.googlegroups.com; posting-host=153.98.68.197; posting-account=pcLQNgkAAAD9TrXkhkIgiY6-MDtJjIlC User-Agent: G2/1.0 X-Google-Web-Client: true X-Google-Header-Order: HUALESRCNK X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.2.8) Gecko/20100728 Firefox/3.6.8 (.NET CLR 3.5.30729),gzip(gfe) Xref: news1.google.com comp.lang.ada:19158 Content-Type: text/plain; charset=ISO-8859-1 Date: 2011-11-25T02:23:22-08:00 List-Id: Dmitry A. Kazakov wrote on comp.lang.ada: > On Thu, 24 Nov 2011 20:46:13 +0100, Ludovic Brenta wrote: > > Constants with other purposes can be declared outside the type > > definition and thus shared among all objects of the declared type. > > The constant value may depend on the enclosing object, undesired or > impossible to re-evaluate each time when needed. IOW, the constant is the cached result of a function taking the rest, or part thereof, of the object as its sole parameter. If this result is a constant, this can only mean that the rest of the object is constant too, right? In this case one can say: type T is record Hash_Value : Natural; Component_1 : Foo; Component_2 : Bar; end record; Object : constant T := (Hash_Value => Hash (Component_1, Component_2), Component_1 => Component_1, Component_2 => Component_2); If not all other components are inputs into the function returning the constant result, then it is probably desirable to split the object into two types, such that all the "constant" components are in a type of their own: type Immutable_Part is record Hash_Value : Natural; Component_1 : Foo; end record; type T (Immutable : not null access constant Immutable_Part) is record Component_2 : Bar; end record; -- Ludovic Brenta.