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,dab7d920e4340f12 X-Google-Attributes: gid103376,public From: fraser@mundook.cs.mu.OZ.AU (Fraser Wilson) Subject: Re: C is 'better' than Ada because... Date: 1996/07/18 Message-ID: <4skpgu$ta@mulga.cs.mu.OZ.AU>#1/1 X-Deja-AN: 168671984 distribution: world references: <31E402B4.55EC@csehp3.mdc.com> <4se1cl$mp@salyko.cube.net> <4sgeme$r32@salyko.cube.net> organization: Comp Sci, University of Melbourne newsgroups: comp.lang.ada Date: 1996-07-18T00:00:00+00:00 List-Id: okellogg@cube.net (Oliver Kellogg) writes: > #include > char *replicate (char c, int times) > { > char *buffer = (char *) malloc (times); > return (char *) memset (buffer, c, times); > } >is not that much less elegant either :-) Well, that's a matter of taste. I prefer the Ada version -- the C one has a lot of really ugly low-level stuff. I mean, typecasts? It looks as though you're trying to do something naughty (but that's a way of life in C, isn't it?). Two advantages that the Ada code has are: 1. it didn't require the caller to clean up allocated memory, and 2. you were able to write it first time without introducing a rather nasty (and common) bug that appears in the C code. Fraser. -- ____ Fraser Wilson | email: fraser@cs.mu.oz.au __o \ / The more I learn of | voice: +61 3 9287 9193 _-\<,_ \/ C++, the more I like | fax: +61 3 9348 1184 (_)/ (_) --- Ada 95 --- | www: http://www.cs.mu.oz.au/~fraser/