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=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no 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-12-05 23:53:23 PST Path: archiver1.google.com!news2.google.com!newsfeed2.dallas1.level3.net!news.level3.com!zeus.visi.com!green.octanews.net!news.octanews.net!news-out.visi.com!petbe.visi.com!newshosting.com!news-xfer2.atl.newshosting.com!216.166.71.118.MISMATCH!small1.nntp.aus1.giganews.com!border1.nntp.aus1.giganews.com!intern1.nntp.aus1.giganews.com!nntp.giganews.com!nntp.rapidnet.com!news.rapidnet.com.POSTED!not-for-mail NNTP-Posting-Date: Sat, 06 Dec 2003 01:53:20 -0600 Date: Sat, 06 Dec 2003 01:48:28 -0600 From: Chad Bremmon Reply-To: bremmon@acm.org User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4) Gecko/20030624 Netscape/7.1 (ax) X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Question about OO programming in Ada References: In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Message-ID: NNTP-Posting-Host: 12.13.119.78 X-Trace: sv3-ypHbyVmqpBOUX/6BCsYV3BVbJz14YtXENem70brMp5S7ebSNeYydOkIctCwZ6DhtaixnZoUKfnnjovp!gn3EtVjtCufmOfu/tK3+3b2ENpkk7Eck2wNXG5npouWfPrh8972DTdxogXK3GDmcOR7NH9j54ScT X-Complaints-To: abuse@rapidnet.com X-DMCA-Complaints-To: abuse@rapidnet.com X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.1 Xref: archiver1.google.com comp.lang.ada:3173 Date: 2003-12-06T01:48:28-06:00 List-Id: I miss Ada, and it's been a while, but not that long. C++ piles a lot of crap, pardon the French into the definition for a class. Somewhere, there is a well documented mapping of UML to Ada95, which is really what you're trying to ask for. Since I'm relatively unemployed right now, if I get resounding request for it, I could write an OO primer for Ada95. I know they're out there, but I haven't seen anyone point you right to one. For now I can tell you these things: 1) class wide types are only valuable for dynamic polymorphism This means that it MUST be a linked list of classwide variables, and the compiler cannot possibly know what the type is going to be. 2) to get OO stuff like inheritance, you must declare your operations directly after the tagged type definition 3) whether you pass an access or an in/inout, (Has nothing to do with OO really. Everyone else is right. Stay away from access types unless you need them) depends on what you're doing with the tagged type once it is passed in. If it is further used, and the variable (on the stack) may become unsafe, then you have to pass an access type so that when the program returns, the procedure can't possibly have kept a pointer to something on the stack and tried to use it after the variable has been popped off the stack I know I'm babbling... Here are key OO features and their associated Ada95 features 1. Inheritance - tagged types 2. Encapsulation - private types 3. Polymorphism - 'Class - also access types 4. Abstraction - packages That's my penny and a half about it. Thanks, Chad Ekkehard Morgenstern wrote: > 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? > > Like, what about: > > procedure A ( B: in access all T ) > > or > > procedure A ( B: in out T ) > > or > > procedure A ( B: in T ) > > Also, if I use access types, should I create new types or declare them > directly in the procedure/function, and what about the 'all' access > qualifier, should I create two types of access types (one with 'access' and > one with 'access all'), or should I declare them directly in the procedure > and decide individually what kind of access I need? > > I would like to program as cleanly as possible in Ada right from the start, > so I'd be glad if someone could give me some hints. :-) > > >