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

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!cs.utexas.edu!zaphod.mps.ohio-state.edu!usc!wupost!darwin.sura.net!uvaarpa!murdoch!virginia.edu!gs4t
  3. From: gs4t@virginia.edu (Gnanasekaran Swaminathan)
  4. Subject: Re: const on pass by value
  5. Message-ID: <1992Jul24.195614.13598@murdoch.acc.Virginia.EDU>
  6. Sender: usenet@murdoch.acc.Virginia.EDU
  7. Reply-To: gs4t@virginia.edu (Gnanasekaran Swaminathan)
  8. Organization: University of Virginia
  9. References:  <1992Jul24.151010.11969@PacBell.COM> <1992Jul24.172325.25348@watson.ibm.com>
  10. Date: Fri, 24 Jul 1992 19:56:14 GMT
  11. Lines: 24
  12.  
  13. mittle@watson.ibm.com (Josh Mittleman) writes:
  14. |> pjcondi@lepton (Paul
  15. |> Condie) writes:
  16. |> 
  17. |> > Should pass by value arguments be declared as "const" for
  18. |> > good coding style?  Or is that nit picking?
  19. |> 
  20. |> A blanket convention makes no sense.
  21. |> 
  22. |> For scalar arguments, it doesn't really matter: The user can see that the
  23. |> argument is passed by value, so he doesn't care whether or not it is const.
  24. |> If you find it convenient, make it a const.
  25.  
  26.  
  27. int f(const int a) {            int f(int a) {
  28.     while(a--) // not possible        while(a--) // quite possible
  29.     {...}                    { ... }
  30. }                    }
  31.  
  32. That is, it matters for the programmer who defines the 
  33. function and it does not matter for the user of the
  34. function.
  35.  
  36. -Sekar
  37.