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 Received: by 10.68.15.105 with SMTP id w9mr567003pbc.7.1322554901002; Tue, 29 Nov 2011 00:21:41 -0800 (PST) Path: lh20ni35889pbb.0!nntp.google.com!news1.google.com!postnews.google.com!cc2g2000vbb.googlegroups.com!not-for-mail From: David Sauvage Newsgroups: comp.lang.ada Subject: Re: Why constant components are not permitted ? Date: Mon, 28 Nov 2011 23:55:49 -0800 (PST) Organization: http://groups.google.com Message-ID: <009a0d10-706d-4c9c-824e-68995676a1ea@cc2g2000vbb.googlegroups.com> References: <1856c00b-1994-406a-bbb3-73d93785099a@i6g2000vbe.googlegroups.com> <9j8sg4FfjuU1@mid.individual.net> <14efc07c-744c-4f9a-905b-b9e3ad353e55@cc2g2000vbb.googlegroups.com> <9ja2aiFla6U1@mid.individual.net> NNTP-Posting-Host: 41.136.233.252 Mime-Version: 1.0 X-Trace: posting.google.com 1322554900 22177 127.0.0.1 (29 Nov 2011 08:21:40 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Tue, 29 Nov 2011 08:21:40 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: cc2g2000vbb.googlegroups.com; posting-host=41.136.233.252; posting-account=RLLoCgoAAAAlrjFze52eMRxLw8Zw6JGC User-Agent: G2/1.0 X-Google-Web-Client: true X-Google-Header-Order: HUALESNKRC X-HTTP-UserAgent: Mozilla/5.0 (X11; Linux i686; rv:7.0.1) Gecko/20100101 Firefox/7.0.1,gzip(gfe) Xref: news1.google.com comp.lang.ada:19228 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Date: 2011-11-28T23:55:49-08:00 List-Id: On 29 nov, 08:10, "Randy Brukardt" wrote: > "Niklas Holsti" wrote in message > > news:9ja2aiFla6U1@mid.individual.net... > ... > > > The original poster specified the constant value in the declaration of = the > > record *type*, not separately for each record *object*. This is what I = do > > not understand: what is the use of a value that is the same for all > > objects in which it can appear? > > One such use is in interfacing when some components always have fixed > values. For instance, most record types in Win32 have a Size component th= at > is always the same for a particular type declaration. It would be nice to > declare that as a constant (since it cannot change). > > But this need is so rare and unusual it hardly makes sense to add languag= e > support for it. The story would be different for a new from-scratch langu= age > design; the omission looks like a mistake in Ada and it surely would be m= ore > consistent to have it even if it is rarely used. But redoing the Standard > and existing implementations needs a better reason than "more consistent = but > rarely used". > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0Randy. Why use a constant attribute in a record ? To expose my design intention in the code. I will have a big tagged types hierarchy, and wanted to declare a read only component in each root tagged types, so that when users will use the framework and add child types, they will not been able to modify this attribute. I would not been able to do this using a primitive method as they would be able to override it (think of the final keywork in Java to prevent a method from being overridden). Anyway, my question concern the rational of why this is not possible in Ada, and I got some answers. Thanks to all for your inputs. Cheers,