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-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,56131a5c3acc678e X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-11-25 12:21:28 PST Path: archiver1.google.com!news2.google.com!news.maxwell.syr.edu!elnk-pas-nf1!newsfeed.earthlink.net!sn-xit-02!sn-xit-01!sn-post-02!sn-post-01!supernews.com!corp.supernews.com!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: Question about OO programming in Ada Date: Tue, 25 Nov 2003 14:17:58 -0600 Organization: Posted via Supernews, http://www.supernews.com Message-ID: References: X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4807.1700 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300 X-Complaints-To: abuse@supernews.com Xref: archiver1.google.com comp.lang.ada:2940 Date: 2003-11-25T14:17:58-06:00 List-Id: "Ekkehard Morgenstern" wrote in message news:bq092s$9ph$1@online.de... > Hi guys, > > I have a question about object-oriented programming in Ada: > > Do I have to use class-wide types for object-oriented programming, or could > I use regular access types? > > Like, when I declare a procedure > > procedure A ( B: in access all T'Class ) > > could I use a different method and still get all the benefits of Ada > object-oriented programming? Yikes! The "in" isn't allowed here, nor is the "all" -- they're both assumed. Second, you are generally best off avoiding access types when you can. That certainly is true of O-O programming as well. Use access types for dynamic structures; don't use them otherwise. procedure A (B : in out T'Class); works just as well and doesn't have explicit access types. When we designed Claw (a thick O-O interface for Windows), we avoided use of access types in the interface in almost all cases. There are a lot of access types in the implementation, but the user of Claw doesn't need to worry about that. That's especially useful for simple programs (for instance, those that declare just a few windows), because Ada can do all of the storage management. Ada allows access types for O-O programming because of a desire to allow people to translate existing O-O designs for C++ and Java directly into Ada. I think that's generally a mistake -- Ada can do better than using explicit pointers. Randy Brukardt.