home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!gatech!destroyer!caen!batcomputer!munnari.oz.au!bunyip.cc.uq.oz.au!kirk!lance!ptcburp!michi
- From: michi@ptcburp.ptcbu.oz.au (Michael Henning)
- Newsgroups: comp.lang.c++
- Subject: Re: const on pass by value
- Message-ID: <1992Jul30.031451.6116@ptcburp.ptcbu.oz.au>
- Date: 30 Jul 92 03:14:51 GMT
- References: <1992Jul24.151010.11969@PacBell.COM> <9220801.5026@mulga.cs.mu.OZ.AU> <1992Jul28.180713.16258@mole-end.matawan.nj.us> <9221212.10105@mulga.cs.mu.OZ.AU>
- Organization: Pyramid Technology Corporation
- Lines: 32
-
- fjh@munta.cs.mu.OZ.AU (Fergus James HENDERSON) 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?
- >>
-
- >Furthermore the only reason why it might affect the confidence of the reader
- >that the variables are not changed is if the reader does not understand the
- >semantics of pass-py-value in C. (If this is the case then the reader,
- >not the program, is broken :-). Besides, the "confidence of the reader" is
- >a fairly dubious thing in general; this is very much a matter of style (ie.
- >"nitpicking").
-
- >Thus I still maintain that it IS just nitpicking.
-
-
- I disagree. If a function declares a parameter as const, and I'm
- reading that function, I can be sure that the value of the parameter will
- be the same as the one passed initially, everywhere in the function body.
-
- If the parameter is not declared const, the function may use it as a local
- variable. If I then see the parameter used towards the end of the function,
- I have to read the entire function body to see whether its value was
- changed.
-
- Michi.
- --
- -m------- Michael Henning +61 75 950255
- ---mmm----- Pyramid Technology +61 75 722475 FAX
- -----mmmmm--- Research Park, Bond University michi@ptcburp.ptcbu.oz.au
- -------mmmmmmm- Gold Coast, Q 4229, AUSTRALIA uunet!munnari!ptcburp.oz!michi
-