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,dad94612ff745427 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news3.google.com!newsfeed2.dallas1.level3.net!news.level3.com!newsfeed-00.mathworks.com!kanaga.switch.ch!switch.ch!newsfeed3.funet.fi!newsfeed1.funet.fi!newsfeeds.funet.fi!feeder1.news.jippii.net!nntp.inet.fi!inet.fi!newsfeed1.nokia.com!news1.nokia.com!not-for-mail From: rick H Subject: Re: Instantiating private types with discriminants? Newsgroups: comp.lang.ada References: <44609cf7$0$11072$9b4e6d93@newsread4.arcor-online.net> Organization: home User-Agent: tin/1.8.1-20060215 ("Mealasta") (UNIX) (CYGWIN_NT-5.1/1.5.19(0.150/4/2) (i686)) Message-ID: <1m18g.28776$Nb2.522087@news1.nokia.com> Date: Tue, 09 May 2006 14:06:53 GMT NNTP-Posting-Host: 172.26.210.110 X-Complaints-To: newsmaster@nokia.com X-Trace: news1.nokia.com 1147183613 172.26.210.110 (Tue, 09 May 2006 17:06:53 EET DST) NNTP-Posting-Date: Tue, 09 May 2006 17:06:53 EET DST Xref: g2news2.google.com comp.lang.ada:4152 Date: 2006-05-09T14:06:53+00:00 List-Id: Georg Bauhaus wrote: > rick H wrote: > > >> So, my question to the experts is: Why does "privatising" a type's >> details change the way that you "new" instantiations of it? > > You cannot write down the private components of a private type > anywhere they are invisible. Even though your private type Type_B > doesn't actually have private components, that isn't known outside > Discrim's private part, i.e. in procedure Use_Discrim . Consider: > > with Discrim; use Discrim; > procedure Use_Discrim is > A_Thing: Type_A; > B_Thing: Type_B; > Another_B_Thing: Type_B(Param => 42); -- declaring with constraint > A : Type_A_Ptr; -- public implementation > B : Type_B_Ptr; -- private implementation > begin > A_Thing := (Param => 100); > B_Thing := (Param => 100); -- what about the private components? > A_Thing := Type_A'(Param => 100); > A_Thing := Type_A (Param => 100); > A := new Type_A'(Param => 100); -- qualified expression > B := new Type_B (Param => 123); -- ? > end Use_Discrim; > Thanks Georg - I understand now! Rick