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