home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!munnari.oz.au!metro!extro.ucc.su.OZ.AU!maxtal
- From: maxtal@extro.ucc.su.OZ.AU (John MAX Skaller)
- Subject: Re: const on pass by value
- Message-ID: <1992Jul24.185201.13330@ucc.su.OZ.AU>
- Sender: news@ucc.su.OZ.AU
- Nntp-Posting-Host: extro.ucc.su.oz.au
- Organization: MAXTAL P/L C/- University Computing Centre, Sydney
- References: <1992Jul24.151010.11969@PacBell.COM>
- Date: Fri, 24 Jul 1992 18:52:01 GMT
- Lines: 40
-
- 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);
- >
-
- you usually declare const.
-
- However: this is a design flaw IMHO in the langauge.
-
- Const value arguments dont make sense: they're copied
- anyhow, so it makes no difference. The reason for having const
- parameters in declarations is that you sometimes want the
- COPIED value in the function *definition* to be const.
-
- But this has nothing to do with the declaration except that
- the language is incapable of distinguishing them.
-
- I think the following should be legal:
-
- void foo (int a);
- void foo (const int a) { .... } // SAME as foo above
-
- My argument breaks down if value parameters are not copied.
- Then 'const' can mean: it is ok to pass this one by reference.
-
- A similar issue applies to const RETURN values from functions.
- And that one is very important and I think not resolved.
-
-
- --
- ;----------------------------------------------------------------------
- JOHN (MAX) SKALLER, maxtal@extro.ucc.su.oz.au
- Maxtal Pty Ltd, 6 MacKay St ASHFIELD, NSW 2131, AUSTRALIA
- ;--------------- SCIENTIFIC AND ENGINEERING SOFTWARE ------------------
-