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