Path: utzoo!attcan!uunet!tut.cis.ohio-state.edu!zaphod.mps.ohio-state.edu!samsung!munnari.oz.au!bruce!goanna!ok From: ok@goanna.cs.rmit.oz.au (Richard A. O'Keefe) Newsgroups: comp.lang.c Subject: Re: Why does C hate 2d arrays? Message-ID: <3065@goanna.cs.rmit.oz.au> Date: 25 May 90 02:14:43 GMT References: <12919@smoke.BRL.MIL> <2429@psuhcx.psu.edu> Organization: Comp Sci, RMIT, Melbourne, Australia Lines: 47 > In article <3060@goanna.cs.rmit.oz.au> I wrote > Heck, if C was all >about primitives, we wouldn't have floating point. Why coddle these weak >programmers by providing a sqrt() function; they have all the primitives >they need to build it themselves. In article <2429@psuhcx.psu.edu>, hannum@schubert.psu.edu (Charles Hannum) writes: > C does not provide a sqrt() function to "coddle the programmer." > Your standard library, on the other hand, may include such a function. Re coddling the programmer, don't you recognise irony when you see it? This thread was concerned with ANSI C. And the standard library *IS* part of ANSI C. sqrt() is not an _optional_ part of ANSI C. > And yes, C *is* all about primitives. > Read "The C Programming Language" if you don't believe this. I have read "The C Programming Language", thanks, many times. C is not about primitives. It is about TRADEOFFS. I repeatedly said in my postings in this thread that C's strength comes from what it left out, which is pretty much a paraphrase of the extract Hannum quoted in his previous posting. For example, malloc() is not a primitive. In UNIX, it used to be built on top of a _real_ primitive, namely brk(). Writing code for a PDP-11, I often used brk() and sbrk() myself because I wanted to keep all that library code *out* to leave room for my data. Can anyone claim that printf() is a primitive, with a straight face? (I would also keep stdio *out* too, it was much too big when I had only 64k to play with and 30k of code and 30k of data...) No, malloc() and printf() are tradeoffs: the extra convenience is worth while, and the price in terms of compiler and library support is not too high. The C philosophy was to provide you with ALL the primitives you need. It was not to provide ONLY the primitives. Adding dynamic arrays to C, *if it could be done without disruption* would not compromise the C philosophy in any way. Only if programmers *had* to use the new dynamic array mechanism *instead* of pointer arithmetic would that be so. Any rate, all that really matters is that C should continue to work as Eiffel's portable assembly code (:-). -- "A 7th class of programs, correct in every way, is believed to exist by a few computer scientists. However, no example could be found to include here."