home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!cs.utexas.edu!zaphod.mps.ohio-state.edu!usc!wupost!darwin.sura.net!uvaarpa!murdoch!virginia.edu!gs4t
- From: gs4t@virginia.edu (Gnanasekaran Swaminathan)
- Subject: Re: const on pass by value
- Message-ID: <1992Jul24.195614.13598@murdoch.acc.Virginia.EDU>
- Sender: usenet@murdoch.acc.Virginia.EDU
- Reply-To: gs4t@virginia.edu (Gnanasekaran Swaminathan)
- Organization: University of Virginia
- References: <1992Jul24.151010.11969@PacBell.COM> <1992Jul24.172325.25348@watson.ibm.com>
- Date: Fri, 24 Jul 1992 19:56:14 GMT
- Lines: 24
-
- mittle@watson.ibm.com (Josh Mittleman) writes:
- |> pjcondi@lepton (Paul
- |> Condie) writes:
- |>
- |> > Should pass by value arguments be declared as "const" for
- |> > good coding style? Or is that nit picking?
- |>
- |> A blanket convention makes no sense.
- |>
- |> For scalar arguments, it doesn't really matter: The user can see that the
- |> argument is passed by value, so he doesn't care whether or not it is const.
- |> If you find it convenient, make it a const.
-
-
- int f(const int a) { int f(int a) {
- while(a--) // not possible while(a--) // quite possible
- {...} { ... }
- } }
-
- That is, it matters for the programmer who defines the
- function and it does not matter for the user of the
- function.
-
- -Sekar
-