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-7-bit Path: g2news1.google.com!news1.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!nx01.iad01.newshosting.com!newshosting.com!198.186.194.249.MISMATCH!news-out.readnews.com!transit3.readnews.com!panix!bloom-beacon.mit.edu!newsswitch.lcs.mit.edu!nntp.TheWorld.com!not-for-mail From: Robert A Duff Newsgroups: comp.lang.ada Subject: Re: Discriminants of tagged types Date: Wed, 27 Oct 2010 09:52:48 -0400 Organization: The World Public Access UNIX, Brookline, MA Message-ID: References: <14314714-e92c-4036-9cbb-da8e72489261@h7g2000yqn.googlegroups.com> <1bytu43t5bi8y.1t3tebqbls31j.dlg@40tude.net> NNTP-Posting-Host: shell01.theworld.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: pcls6.std.com 1288187555 19668 192.74.137.71 (27 Oct 2010 13:52:35 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Wed, 27 Oct 2010 13:52:35 +0000 (UTC) User-Agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.3 (irix) Cancel-Lock: sha1:Jq6YNAOpxYkntsy8Bm45970PRPc= Xref: g2news1.google.com comp.lang.ada:14830 Date: 2010-10-27T09:52:48-04:00 List-Id: "Dmitry A. Kazakov" writes: > On Wed, 27 Oct 2010 05:34:26 -0700 (PDT), Ludovic Brenta wrote: > >> 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). > > No, it would not because you cannot assign a value of another type. I think Ludovic means that the Tag could change. That is, tags are sort of like discriminants, so if Tags could have defaults, then we can guess that they would inherit the strange rule "can change if defaulted". So this would work: A : T1; B : T'Class := A; C : T2; B := C; -- Raises an exception. >> Therefore, *additional* discriminants cannot have default values either. > > I think there were concerns about implementation difficulties when the > derived type adds new discriminants and/or defines some inherited ones. > > Anyway the limitation is indeed annoying. Then you won't like my opinion, which is that this feature should never have existed even for untagged types. It's useful, but it's just not worth the trouble, in terms of programmer confusion, and implementation difficulty. Also nonportability: type T(Length: Natural := 0) is record S: String(1..Length); end record; This works on some implementations, and not others. - Bob