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: a07f3367d7,4ce5890331a5b529 X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII Path: g2news1.google.com!postnews.google.com!30g2000yqm.googlegroups.com!not-for-mail From: Ludovic Brenta Newsgroups: comp.lang.ada Subject: Re: Discriminants of tagged types Date: Wed, 27 Oct 2010 05:34:26 -0700 (PDT) Organization: http://groups.google.com Message-ID: References: <14314714-e92c-4036-9cbb-da8e72489261@h7g2000yqn.googlegroups.com> NNTP-Posting-Host: 153.98.68.197 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1288182866 24596 127.0.0.1 (27 Oct 2010 12:34:26 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Wed, 27 Oct 2010 12:34:26 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: 30g2000yqm.googlegroups.com; posting-host=153.98.68.197; posting-account=pcLQNgkAAAD9TrXkhkIgiY6-MDtJjIlC User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.0.6) Gecko/2009012111 Red Hat/3.0.6-1.el5 Firefox/3.0.6,gzip(gfe) Xref: g2news1.google.com comp.lang.ada:14826 Date: 2010-10-27T05:34:26-07:00 List-Id: Maciej Sobczak wrote on comp.lang.ada: > I'm not sure if I have already complatined about it, but as I have hit > that problem again, here it goes: > > GNAT says that discriminants of tagged types cannot have default > values. > So this is OK: > > =A0 =A0type T (A : Integer :=3D 0) is null record; > > but this is an error: > > =A0 =A0type T (A : Integer :=3D 0) is tagged null record; > > I find it disturbing and artificial, but perhaps I don't see the big > picture. What is the rationale for this limitation? If one discriminant has a default value, then all discriminants must have default values (ARM 3.7(9.1/2)). The reason is explained in the Annotated Ada Reference Manual[1]. http://www.adaic.com/standards/05aarm/html/AA-3-7.html Tagged types have, by definition, a hidden discriminant which is the tag. The tag has no default value and cannot have one, for that would allow changing the type of an object at run time (through assignment of an aggregate). Therefore, *additional* discriminants cannot have default values either. -- Ludovic Brenta.