home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / lang / cplus / 11818 < prev    next >
Encoding:
Internet Message Format  |  1992-07-30  |  1.9 KB

  1. Path: sparky!uunet!gatech!destroyer!caen!batcomputer!munnari.oz.au!bunyip.cc.uq.oz.au!kirk!lance!ptcburp!michi
  2. From: michi@ptcburp.ptcbu.oz.au (Michael Henning)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: const on pass by value
  5. Message-ID: <1992Jul30.031451.6116@ptcburp.ptcbu.oz.au>
  6. Date: 30 Jul 92 03:14:51 GMT
  7. References: <1992Jul24.151010.11969@PacBell.COM> <9220801.5026@mulga.cs.mu.OZ.AU> <1992Jul28.180713.16258@mole-end.matawan.nj.us> <9221212.10105@mulga.cs.mu.OZ.AU>
  8. Organization: Pyramid Technology Corporation
  9. Lines: 32
  10.  
  11. fjh@munta.cs.mu.OZ.AU (Fergus James HENDERSON) writes:
  12.  
  13. >>> >In article <1992Jul24.151010.11969@PacBell.COM>, pjcondi@lepton (Paul Condie) writes:
  14. >>> >> Should pass by value arguments be declared as "const" for
  15. >>> >> good coding style?  Or is that nit picking?
  16. >>
  17.  
  18. >Furthermore the only reason why it might affect the confidence of the reader
  19. >that the variables are not changed is if the reader does not understand the
  20. >semantics of pass-py-value in C. (If this is the case then the reader,
  21. >not the program, is broken :-). Besides, the "confidence of the reader" is
  22. >a fairly dubious thing in general; this is very much a matter of style (ie.
  23. >"nitpicking").
  24.  
  25. >Thus I still maintain that it IS just nitpicking.
  26.  
  27.  
  28. I disagree. If a function declares a parameter as const, and I'm
  29. reading that function, I can be sure that the value of the parameter will
  30. be the same as the one passed initially, everywhere in the function body.
  31.  
  32. If the parameter is not declared const, the function may use it as a local
  33. variable. If I then see the parameter used towards the end of the function,
  34. I have to read the entire function body to see whether its value was
  35. changed.
  36.  
  37.                             Michi.
  38. -- 
  39.       -m------- Michael Henning                 +61 75 950255
  40.     ---mmm----- Pyramid Technology              +61 75 722475 FAX
  41.   -----mmmmm--- Research Park, Bond University  michi@ptcburp.ptcbu.oz.au
  42. -------mmmmmmm- Gold Coast, Q 4229, AUSTRALIA   uunet!munnari!ptcburp.oz!michi
  43.