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,7009541db2ced1ad X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news2.google.com!news1.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!nx01.iad.newshosting.com!newshosting.com!newsfeed.icl.net!newsfeed.fjserv.net!oleane.net!oleane!news.ecp.fr!news.jacob-sparre.dk!pnx.dk!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: Construction initialization problem Date: Thu, 4 Dec 2008 16:17:56 -0600 Organization: Jacob Sparre Andersen Message-ID: References: NNTP-Posting-Host: static-69-95-181-76.mad.choiceone.net X-Trace: munin.nbi.dk 1228429138 17299 69.95.181.76 (4 Dec 2008 22:18:58 GMT) X-Complaints-To: news@jacob-sparre.dk NNTP-Posting-Date: Thu, 4 Dec 2008 22:18:58 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5512 X-RFC2646: Format=Flowed; Original X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5579 Xref: g2news1.google.com comp.lang.ada:2879 Date: 2008-12-04T16:17:56-06:00 List-Id: "Dmitry A. Kazakov" wrote in message news:oscmgxrpod50$.g7h7snlssha0$.dlg@40tude.net... > Consider this: > > type A is tagged limited null record; > type B (X : not null access A'Class) is tagged limited null record; > > Now we want to specialize B so that its instances would already contain A: You never explained why you would want the discriminant in the first place. I would think that it would be better to do what you've said about C (include the instance directly in it) from the beginning, and the problem doesn't come up. Access discriminants have a fairly high overhead in Ada (because of the possibility of coextensions), so unless you *need* coextensions, they ought to be avoided. One could use a named access type instead to declare the discriminant if you really need a discriminant. But the only time you must use a discriminant is if you have a discriminant-dependent component, and there is no interesting way to make a component dependent on an access discriminant. So I'd prefer to just avoid the discriminant. If you're using discriminants to stand in for a proper constructor, I say "don't!!" Use a constructor function as the language intends (and force it with a (<>) if you need it). Randy. > type C is new B with record > Y : aliased A; > end record; > > Now there seems no way to either create an object of C so that C.X would > point to C.Y or else to derive from C a new type without discriminant: > > type D is new C (X => C.Y'Access) with null record; -- Illegal > type D is new C (X => D.Y'Access) with null record; -- Illegal > > -- > Regards, > Dmitry A. Kazakov > http://www.dmitry-kazakov.de