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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,900edaa189af2033 X-Google-Attributes: gid103376,public From: Ken Garlington Subject: Re: Ada95 OOP Questions Date: 1996/07/30 Message-ID: <31FE03CB.7B74@lmtas.lmco.com>#1/1 X-Deja-AN: 171197758 references: <4tf3l4$4hu@masala.cc.uh.edu> <4tgi88$5fi@Masala.CC.UH.EDU> content-type: text/plain; charset=us-ascii organization: Lockheed Martin Tactical Aircraft Systems mime-version: 1.0 newsgroups: comp.lang.ada x-mailer: Mozilla 2.02 (Macintosh; I; 68K) Date: 1996-07-30T00:00:00+00:00 List-Id: Spasmo wrote: > Well here's the thing though, from what I'm seeing when you > use the package you'd need to pass the parameters to the > subprograms rather than having the data encapsulated. For > instance in C++ you'd do the following: > > Person p; > p.walk(); > p.talk(); > p.eat(); > > But with the above you'd do something like the following: > (Any Ada code provided may be slightly erroneous, I just want > to give a general idea of what I think I understand hence not > checking much). > > with Persons; > > procedure Main is > > P : Persons.Person; > > begin > Persons.Walk(P); > Persons.Talk(P); > Persons.Eat(P); > end Main; > > Correct me if I'm wrong on this. So you're still passing parameters > which means that data and subprograms are still 2 different entities > which sorta hurts the abstraction, rather than in say C++ where > you've got a unified object. Depends on what you're abstrating. If you don't want an abstract data type, but you want a generic abstract data object, why not do this: generic package Person is procedure Walk; procedure Talk; procedure Eat; private type Person_Type is -- as before Object : Person_Type; end Person; Translating your C++ code: package P is new Person; -- Person p; P.Walk; -- p.walk(); P.Talk; -- p.talk(); P.Eat; -- p.eat(); Note, however, that there are things you can't do with a GADO (like make an array of Persons) that you can do with an ADT. If your complaint is that you like p.eat() better than eat(p), on the other hand, then I don't see this as an abstraction difference - just a syntax difference. Just out of curiousity, if Person is declared in the C++ equivalent of a package (and I forget the nomenclature -- space?), what does your C++ code look like? -- LMTAS - "Our Brand Means Quality"