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,FREEMAIL_FROM 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,UTF8 Received: by 10.68.35.68 with SMTP id f4mr10953041pbj.5.1322214828894; Fri, 25 Nov 2011 01:53:48 -0800 (PST) Path: lh20ni16011pbb.0!nntp.google.com!news1.google.com!goblin3!goblin.stu.neva.ru!gegeweb.org!aioe.org!.POSTED!not-for-mail From: =?utf-8?Q?Yannick_Duch=C3=AAne_=28Hibou57?= =?utf-8?Q?=29?= Newsgroups: comp.lang.ada Subject: Re: Why constant components are not permitted ? Date: Fri, 25 Nov 2011 10:53:47 +0100 Organization: Ada @ Home Message-ID: References: <1856c00b-1994-406a-bbb3-73d93785099a@i6g2000vbe.googlegroups.com> <9j8sg4FfjuU1@mid.individual.net> NNTP-Posting-Host: IQsgShqvlwBVRETOGaH4CQ.user.speranza.aioe.org Mime-Version: 1.0 X-Complaints-To: abuse@aioe.org User-Agent: Opera Mail/11.60 (Linux) X-Notice: Filtered by postfilter v. 0.8.2 Xref: news1.google.com comp.lang.ada:19151 Content-Type: text/plain; charset=utf-8; format=flowed; delsp=yes Content-Transfer-Encoding: Quoted-Printable Date: 2011-11-25T10:53:47+01:00 List-Id: Le Fri, 25 Nov 2011 07:56:03 +0100, Niklas Holsti = a =C3=A9crit: > On 11-11-24 19:14 , David Sauvage wrote: >> Hello, >> >> given the following : >> >> type Object is record >> Tag : constant String :=3D "key"; -- GNAT compilation failed : >> constant components are not permitted >> end record; >> >> In my case I find it useful to declare my Object Tag component as a >> constant, but it is not permitted, I would be interested to learn >> why ? > > It seems no earlier responder has understood why you want to have a = > constant component, nor do I, so I'll ask directly: Why do you think a= = > constant component would be useful? The same question for me. A record, is not an interface, that's an = implementation solution. One want to use a record to store some aggregat= ed = stuff, thus its name, =E2=80=9Crecord=E2=80=9D. If a type T is implemented as a record, the interface should not expose = = the record (as with any implementation details, except if part of an = expected specification). If T is to be associated with a constant, the = constant could be implemented as a function getting a T as parameter, an= d = returning that constant. Unless the OP was to reinvent a wheel already provided by Ada, which is = = record discriminant. If that constant is a kind of characterization of = instances of T, then a discriminant is the obvious choice. -- = =E2=80=9CSyntactic sugar causes cancer of the semi-colons.=E2=80=9D [1] =E2=80=9CStructured Programming supports the law of the excluded muddle.= =E2=80=9D [1] [1]: [Epigrams on Programming =E2=80=94 Alan J. =E2=80=94 P. Yale Univer= sity]