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.8 required=5.0 tests=BAYES_00,INVALID_DATE autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 109fba,ef0074ec236ba6e3 X-Google-Attributes: gid109fba,public X-Google-Thread: 108717,ef0074ec236ba6e3 X-Google-Attributes: gid108717,public X-Google-Thread: 103376,b19fa62fdce575f9 X-Google-Attributes: gid103376,public X-Google-Thread: 1108a1,ef0074ec236ba6e3 X-Google-Attributes: gid1108a1,public X-Google-Thread: 1014db,ef0074ec236ba6e3 X-Google-Attributes: gid1014db,public X-Google-ArrivalTime: 1994-11-29 08:11:56 PST Path: bga.com!news.sprintlink.net!hookup!olivea!charnel.ecst.csuchico.edu!xmission!news.cc.utah.edu!swillden From: swillden@fcom.cc.utah.edu (Shawn Willden) Newsgroups: comp.lang.ada,comp.lang.c,comp.programming,comp.lang.c++,comp.object Subject: Re: What is OO (Was Why don't large companies use Ada?) Followup-To: comp.lang.ada,comp.lang.c,comp.programming,comp.lang.c++,comp.object Date: 29 Nov 1994 15:48:24 GMT Organization: University Of Utah Computer Center Distribution: world Message-ID: <3bfig8$tn@news.cc.utah.edu> References: <3b9s8d$m58@cleese.apana.org.au> NNTP-Posting-Host: icarus.weber.edu X-Newsreader: TIN [version 1.1 PL8] Xref: bga.com comp.lang.ada:8057 comp.lang.c:32381 comp.programming:5461 comp.lang.c++:38712 comp.object:9089 Date: 1994-11-29T15:48:24+00:00 List-Id: Andrew Dunstan (andrew@bugalugs.apana.org.au) wrote: : In article <5918@gec-mrc.co.uk>, paj@gec-mrc.co.uk (Paul Johnson) writes: : |> Yes, but you missed out inheritance. What you have described is the : |> object *based* techniques. Object *oriented* techniques allow the : |> programmer to describe new classes of objects in terms of their : |> similarity to existing classes. This is impossible in some : |> traditional languages (e.g Ada) and very difficult in others (e.g C). : |> That was the main push behind the development of OO languages. : Your statement implies that this is more possible in C than in Ada83. : Would you care to justify that? I've written a lot in both, and AFAIK : there is nothing at all more you can do in this line in C than in Ada83. : Rather the reverse. It's definitely *easier* to do in C, however. For example: typedef struct abstractBaseClassStruct { int (*foo)(struct abstractBaseClassStruct*); } AbstraceBaseClass; typedef struct { int (*foo)(AbstractBaseClass*); int x; } DerivedClass; int derivedFoo(AbstractBaseClass* a) { return ((DerivedClass*)a)->x; } void initBase(struct AbstractBaseClass* a) { a.foo = 0; } void initDerived(DerivedClass* a) { a.foo = derivedFoo; } int main() { DerivedClass d; AbstractBaseClass* a; initDerived(&d); a = (AbstractBaseClass*)&d; /* Okay since structures are same */ a->foo(a); /* calls derivedFoo */ } Doing this in C for a non-trivial program is hard. Doing it in Ada would be even more difficult, involving some sort of selectors that would be passed to a global function to emulate function pointers, and I'm not sure it could even be guaranteed to work (are Ada records guaranteed to always have the same layout?). -- Shawn Willden swillden@icarus.weber.edu