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,c890e6ab3fb2c5fc X-Google-Attributes: gid103376,public X-Google-Thread: 109fba,c890e6ab3fb2c5fc X-Google-Attributes: gid109fba,public X-Google-ArrivalTime: 1995-01-25 10:18:09 PST Path: nntp.gmd.de!newsserver.jvnc.net!nntpserver.pppl.gov!princeton!gw1.att.com!csn!ncar!gatech!howland.reston.ans.net!spool.mu.edu!olivea!wetware!barrnet.net!rational.com!rlk From: rlk@rational.com (Bob Kitzberger) Newsgroups: comp.lang.ada,comp.lang.c++ Subject: Re: ADA Objects Help! Followup-To: comp.lang.ada,comp.lang.c++ Date: 25 Jan 1995 18:18:09 GMT Organization: Rational Software Corporation Message-ID: <3g64l1$e7u@rational.rational.com> References: <3f9g1u$j4m@nps.navy.mil> <3flk3r$8qj@gdls.com> <3fu6qc$pc5@gnat.cs.nyu.edu> <3g3uc0$hm6@watnews1.watson.ibm.com> <3g49bu$7fv@nps.navy.mil> NNTP-Posting-Host: bonnie.rational.com X-Newsreader: TIN [version 1.2 PL2] Xref: nntp.gmd.de comp.lang.ada:18308 comp.lang.c++:88050 Date: 1995-01-25T18:18:09+00:00 List-Id: swdecato@nps.navy.mil wrote: : In Ada the same program would be: : : Run(objectPtr); : Sleep(objectPtr); : Move(objectPtr); : Set(objectPtr, A, B); May I suggest an idiom that works better? First, rid yourself of the concept of "pointers" and "structs" when dealing with object-based Ada. This may matter in the class implementation (package body), but clients should be oblivious. Second, name the package after the class you are modeling. The package package should export a type of that class (around here we just use the identifier "Object", and often add some sort of "Object_Collection" type if we want to export a list/set/map/whatever without having to create a new package) Third, use fully qualified names: My_Mower : Lawnmower.Object := Lawnmower.Create( Lawnmower.Toro ); begin Robot_Arm.Run( My_Mower ); Robot_Arm.Sleep( My_Mower ); Robot_Arm.Move( My_Mower ); Robot_Arm.Destroy( My_Mower ); end; If Lawnmower.Object is dynamically allocated, then that is hidden in in Create and Destroy (this is Ada83...) One trap in learning a new language is to try to apply old idioms to the new language; asking around on Usenet is a great way to find idioms specific to the language. .Bob. -- Bob Kitzberger +1 (916) 274-3075 rlk@rational.com Rational Software Corp., 10565 Brunswick Rd. #11, Grass Valley, CA 95945 "Though the boys throw stones at frogs in sport, yet the frogs do not die in sport but in earnest." - Plutarch