lcc.dan@UCLA-LOCUS.ARPA (Dan McMullen) (07/12/85)
having perused the discussion of 'i++' vs. 'i = i + 1' for a few weeks now, i am reminded a little of the Light Beer commercial - 'Tastes great!' vs. 'Less Filling'. at any rate, to throw a new (or maybe old) worm on the pile, consider the operation of incrementing a pointer: int *ip; ip++; vs. ip = ip + 1; this may be a case where the '++' construct is clearer. any comments? for myself, the '++' construct in general is more *intuitive* than the altern- ative. it denotes a *single* operation, whether on an interger or a pointer, whereas 'i = i + 1' denotes two (or three if fetching the value of 'i' is included. this is a beneficial economy of thought as i read a program. what is intuitive for me, however, may not be as intuitive for others, and the discussion goes on. thanks to all who contribute. the exchange is both enjoy- able and instructive for me. dan
ken@turtlevax.UUCP (Ken Turkowski) (07/15/85)
In article <11536@brl-tgr.ARPA> lcc.dan@UCLA-LOCUS.ARPA (Dan McMullen) writes: >consider the operation of incrementing a pointer: > int *ip; > > ip++; > vs. > ip = ip + 1; >this may be a case where the '++' construct is clearer. any comments? > >for myself, the '++' construct in general is more *intuitive* than the altern- >ative. it denotes a *single* operation, whether on an interger or a pointer, >whereas 'i = i + 1' denotes two (or three if fetching the value of 'i' is >included. this is a beneficial economy of thought as i read a program. Also, saying "ip = ip + 1" implies that the pointer is incremented by 1, rather than by one int size, which may be 2 or 4. "ip++" implies "advance to the next element". -- Ken Turkowski @ CADLINC, Menlo Park, CA UUCP: {amd,decwrl,hplabs,nsc,seismo,spar}!turtlevax!ken ARPA: turtlevax!ken@DECWRL.ARPA