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.35.131 with SMTP id h3mr9047085pbj.1.1322163974961; Thu, 24 Nov 2011 11:46:14 -0800 (PST) Path: lh20ni13832pbb.0!nntp.google.com!news2.google.com!news.glorb.com!feeder.erje.net!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail From: Ludovic Brenta Newsgroups: comp.lang.ada Subject: Re: Why constant components are not permitted ? Date: Thu, 24 Nov 2011 20:46:13 +0100 Organization: A noiseless patient Spider Message-ID: <87lir5tibe.fsf@ludovic-brenta.org> References: <1856c00b-1994-406a-bbb3-73d93785099a@i6g2000vbe.googlegroups.com> Mime-Version: 1.0 Injection-Info: mx04.eternal-september.org; posting-host="g2RhiVlqA+ilFWM9SHQr7g"; logging-data="8075"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19nsA/OzWg90HtPa1v14FFo" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3 (gnu/linux) Cancel-Lock: sha1:3O1eJIr/mxuakMDqIs5XPo17ZJs= sha1:X4a84JttFH2id62LWnNg5ic/WEU= Xref: news2.google.com comp.lang.ada:14610 Content-Type: text/plain; charset=us-ascii Date: 2011-11-24T20:46:13+01:00 List-Id: David Sauvage writes on comp.lang.ada: > Hello, > > given the following : > > type Object is record > Tag : constant String := "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? Maybe because you don't need constant components. If the purpose of a constant component is to identify the non-tagged type of an object, then both the programmer and the compiler know the type at compile time. If the purpose is to identify the tagged type of an object, then the compiler emits a tag as part of the representation of each object for this purpose. This tag is normally a pointer to the table of primitive operations for the type (see ARM 3.9(3)). The programmer can query and use the tag, see ARM 3.9(18.1/2 and following), also indirectly through streams, see ARM 13.13.2(31/2, 34/2). Constants with other purposes can be declared outside the type definition and thus shared among all objects of the declared type. -- Ludovic Brenta.