home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / lang / c / 19482 < prev    next >
Encoding:
Text File  |  1993-01-09  |  2.2 KB  |  52 lines

  1. Newsgroups: comp.lang.c
  2. Path: sparky!uunet!stanford.edu!nntp.Stanford.EDU!dkeisen
  3. From: dkeisen@leland.Stanford.EDU (Dave Eisen)
  4. Subject: Re: Moving from Pascal to C
  5. Message-ID: <1993Jan10.003223.21578@leland.Stanford.EDU>
  6. Sender: news@leland.Stanford.EDU (Mr News)
  7. Organization: Sequoia Peripherals, Inc.
  8. References: <4293@dozo.and.nl> <726510754snz@panache.demon.co.uk> <lkupqvINNnvt@exodus.Eng.Sun.COM>
  9. Date: Sun, 10 Jan 93 00:32:23 GMT
  10. Lines: 40
  11.  
  12. In article <lkupqvINNnvt@exodus.Eng.Sun.COM> linden@positive.Eng.Sun.COM (Peter van der Linden) writes:
  13. >
  14. >From: raph@panache.demon.co.uk (Raphael Mankin)
  15. >> IMHO the only thing one can say about pointer arithmetic is DON'T.
  16. >
  17. >> If your pointer points to an array, use subscripting. 
  18. >> If your pointer is to a single item, then the only thing you should do with 
  19. >> it is to follow it (dereference).
  20. >
  21. >And what if your pointer points to neither an array, nor a single item?
  22. >But to say, a block of dynamically-malloc'd memory?
  23.  
  24. I don't agree with Raphael's advice, but he does have a point.
  25. Many programmers don't find pointer arithmetic as natural as
  26. array indexing and for them (or for people who have such programmers
  27. on their maintenance staff!) his advice makes sense.
  28.  
  29. The advice is just as valid when the pointer points to a block 
  30. of memory returns by {m,re,c}alloc as it does with an array.
  31. You certainly can use array indexing or ordinary indirection
  32. most of the time when using dynamically allocated memory.
  33.  
  34. >The advice above is not too surprising, coming from someone who prefers
  35. >to hire programmers with "a degree in English or History or Physics, or 
  36. >anything except CS."
  37. >Maybe if you hired a few CS grad's, you'd know more about these other 
  38. >corners of C.
  39.  
  40. This really isn't called for. I see no evidence that Raphael
  41. is a second rate programmer. Writing readable and easily
  42. maintainable code is important no matter how good a programmer
  43. you are. And one can certainly make a case that pointer arithmetic
  44. makes code more difficult to understand.
  45.  
  46.  
  47. -- 
  48. Dave Eisen                               Sequoia Peripherals: (415) 967-5644
  49. dkeisen@leland.Stanford.EDU              Home:                (415) 321-5154
  50.        There's something in my library to offend everybody. 
  51.           --- Washington Coalition Against Censorship
  52.