home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / lang / cplus / 11538 < prev    next >
Encoding:
Text File  |  1992-07-25  |  1.5 KB  |  42 lines

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!munnari.oz.au!cs.mu.OZ.AU!munta.cs.mu.OZ.AU!fjh
  3. From: fjh@munta.cs.mu.OZ.AU (Fergus James HENDERSON)
  4. Subject: Re: const on pass by value
  5. Message-ID: <9220801.5026@mulga.cs.mu.OZ.AU>
  6. Sender: news@cs.mu.OZ.AU
  7. Organization: Computer Science, University of Melbourne, Australia
  8. References: <1992Jul24.151010.11969@PacBell.COM> <1992Jul25.071559.4236@uunet.uu.net!mole-end>
  9. Date: Sat, 25 Jul 1992 15:58:14 GMT
  10. Lines: 30
  11.  
  12. mat@uunet.uu.net!mole-end writes:
  13.  
  14. >In article <1992Jul24.151010.11969@PacBell.COM>, pjcondi@lepton (Paul Condie) writes:
  15. >> Should pass by value arguments be declared as "const" for
  16. >> good coding style?  Or is that nit picking?
  17. >> For example:
  18. >> void foo (const int a);
  19. >> or
  20. >> void foo (int a);
  21. >
  22. >It's not nitpicking.  It's part of something called const correctness.
  23. >Your program has it or doesn't.  Programs that have it are almost immune
  24. >to a certain large family of errors.
  25.  
  26. Huh? In this example, it IS just nitpicking.
  27. How could the presence or absence of const in the declaration for foo
  28. affect the program's const correctness?
  29.  
  30. For pass-by-value arguments, using const is a matter of taste.
  31. Personally I don't bother: programs have been traditionally written without
  32. const in these cases, and I don't see any reason to change.
  33. (Besides, this avoids unnecessary typing :-)
  34.  
  35. -- 
  36. Fergus Henderson             fjh@munta.cs.mu.OZ.AU      
  37. This .signature VIRUS is a self-referential statement that is true - but 
  38. you will only be able to consistently believe it if you copy it to your own
  39. .signature file!
  40.