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,start X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!t-online.de!130.59.10.21.MISMATCH!kanaga.switch.ch!switch.ch!newsfeed3.funet.fi!newsfeeds.funet.fi!195.197.54.118.MISMATCH!feeder2.news.jippii.net!feeder1.news.jippii.net!nntp.inet.fi!inet.fi!newsfeed1.nokia.com!news1.nokia.com!not-for-mail From: rick H Subject: Instantiating private types with discriminants? Newsgroups: comp.lang.ada 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: Date: Tue, 09 May 2006 13:17:36 GMT NNTP-Posting-Host: 172.26.210.110 X-Complaints-To: newsmaster@nokia.com X-Trace: news1.nokia.com 1147180656 172.26.210.110 (Tue, 09 May 2006 16:17:36 EET DST) NNTP-Posting-Date: Tue, 09 May 2006 16:17:36 EET DST Xref: g2news2.google.com comp.lang.ada:4148 Date: 2006-05-09T13:17:36+00:00 List-Id: Hello, I'm slowly learning Ada for my own amusement, and I've ground to a halt trying to understand something. If some kind sole could explain it to me, I'd be very grateful. I've defined two types, each with a descriminant, and each with its own access type. One of the type's implementations is, however, private: package Discrim is type Type_A (Param : Integer := 100) is null record; type Type_A_Ptr is access Type_A; -- same as above, but implementation now private... type Type_B (Param : Integer := 100) is private; type Type_B_Ptr is access Type_B; private type Type_B (Param : Integer := 100) is null record; end Discrim; When I use "new" on two variables declared as Type_A_Ptr and Type_B_Ptr, one requires a type conversion for the discriminant, whereas the other requires a qualified expression: with Discrim; use Discrim; procedure Use_Discrim is A : Type_A_Ptr; -- public implementation B : Type_B_Ptr; -- private implementation begin A := new Type_A'(Param => 100); -- qualified expression B := new Type_B (Param => 123); -- type conversion end Use_Discrim; So, my question to the experts is: Why does "privatising" a type's details change the way that you "new" instantiations of it? Thanks very much, Rick