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

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!titan!lpi!pkt
  3. From: pkt@lpi.liant.com (Scott Turner)
  4. Subject: Re: const on pass by value
  5. Message-ID: <1992Jul27.174500.296@lpi.liant.com>
  6. Sender: pkt@lpi (Scott Turner)
  7. Organization: Liant Software Corporation
  8. References:  <1992Jul24.151010.11969@PacBell.COM> <1992Jul24.172325.25348@watson.ibm.com>
  9. Date: Mon, 27 Jul 1992 17:45:00 GMT
  10. Lines: 25
  11.  
  12. mittle@watson.ibm.com (Josh Mittleman) writes:
  13. |> pjcondi@lepton (Paul Condie) writes:
  14. |> 
  15. |> > Should pass by value arguments be declared as "const" for
  16. |> > good coding style?  Or is that nit picking?
  17.  
  18. It's not a matter of declaration style, because the declaration must agree
  19. with the function definition.
  20.  
  21. |> For scalar arguments, it doesn't really matter: The user can see that the
  22. |> argument is passed by value, so he doesn't care whether or not it is const.
  23. |> If you find it convenient, make it a const.
  24. |> 
  25. |> For struct or class arguments, it may make a difference, and it is
  26. |> important to tell the user whether you will change the argument or not.
  27. |> Use const appropriately.
  28.  
  29. For struct or class arguments passed by value, it's the same as scalars.
  30. Whether you change the by-value parameter or not, the parameter is destroyed 
  31. when the function returns, so it doesn't matter to the caller.
  32. --
  33. Prescott K. Turner, Jr.
  34. Liant Software Corp. (developers of LPI languages)
  35. 959 Concord St., Framingham, MA 01701 USA    (508) 872-8700
  36. UUCP: uunet!lpi!pkt                          Internet: pkt@lpi.liant.com
  37.