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,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,fcc68f44249afbd4 X-Google-Attributes: gid103376,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!postnews.google.com!m37g2000prh.googlegroups.com!not-for-mail From: Gerd Newsgroups: comp.lang.ada Subject: Re: Translating C++ class types into Ada tagged types? Date: Wed, 18 Jul 2007 03:27:51 -0700 Organization: http://groups.google.com Message-ID: <1184754471.663273.202270@m37g2000prh.googlegroups.com> References: <1184038007.190905.237050@x35g2000prf.googlegroups.com> NNTP-Posting-Host: 62.159.113.204 Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" X-Trace: posting.google.com 1184754472 6228 127.0.0.1 (18 Jul 2007 10:27:52 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Wed, 18 Jul 2007 10:27:52 +0000 (UTC) In-Reply-To: User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727),gzip(gfe),gzip(gfe) Complaints-To: groups-abuse@google.com Injection-Info: m37g2000prh.googlegroups.com; posting-host=62.159.113.204; posting-account=ps2QrAMAAAA6_jCuRt2JEIpn5Otqf_w0 Xref: g2news1.google.com comp.lang.ada:16508 Date: 2007-07-18T03:27:51-07:00 List-Id: tmo...@acm.org schrieb: > You can force the user to give an initial age by > > package Animals is > type Cat(Initial_Age : Positive) is tagged private; > ... > type Cat(Initial_Age : Positive) is tagged record > Age : Positive := Initial_Age; > end record; > ... > Frisky : Animals.Cat(Initial_Age => 0); > If you want the initialization to be significantly more complicated > than that, you can make type Cat controlled, with Initialize and > Finalize procedures. Is this dot notation a new feature of Ada 2005? As far as I know (my own trials, long ago) it is not possible with Ada95. Frisky : Animals.Cat(Initial_Age => 0); Lets assume the following code (maybe not syntactically correct), would it work this way, or how would it be done? package Vehicle is type Car is tagged record NrWheels : Positive := 4; end record; function Wheels (c : Car'Class) return Positive; end Vehicle; with Vehicle package TransportCar is type BigCar is new Car with record Seats : Positive; end record; function Seats (bc : BigCar) return Positive; end TransportCar; ... with Car; with TransportCar; MyCar : TransportCar; ... nrseat := MyCar.Seats; nswheels := MyCar.Wheels; Does the compiler know where the functions come from, or must I write it like in nrwheels := Car.Wheels (MyCar); nrseats := TransportCar.Seat(MyCar)