Article View: comp.std.c++
Article #2289relaxing const match on function implementation
From: Alan Griffiths
Date: Tue, 24 Oct 1995 00:22
Date: Tue, 24 Oct 1995 00:22
37 lines
2043 bytes
2043 bytes
In the interests of hiding implemetation details it seems to me that
a function that does not amend an object passed as a formal parameter
should be able to declare that parameter as "const" without requiring
the same of a function prototype.
For example:
void f(int a); // prototype in a shared header file.
void f(const int a) {} // Implementation of above.
This relaxation would allow the compiler to verify the use of "a" within
the function body without cluttering up the interface declaration with
"const" keywords which do not impact client code.
This should not break any existing code.
Is this a good idea, or am I missing something?
PS
The relaxation only applies to the parameters _not_ to (for example) the
objects that the parameters reference.
e.g. void f(const int& a) {} doesn't match void f(int& a);
void f(int* const a) {} matches void f(int* a);
--
Alan Griffiths | Also editor of: The ISDF Newsletter
Senior Systems Consultant, | (An Association of C and C++ Users publication)
CCN Group Limited. | (ISDF editor : isdf@octopull.demon.co.uk)
(agriffiths@ma.ccngroup.com) | (For ACCU see : http://bach.cis.temple.edu/accu)
---
[ comp.std.c++ is moderated. Submission address: std-c++@ncar.ucar.edu.
Contact address: std-c++-request@ncar.ucar.edu. The moderation policy
is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
Technical Details
Message-ID:
<814452107snz@ma.ccngroup.com>Path:
arc1-ca.pugleaf.net!in2.uu.net!bounce-backShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!in2.uu.net!bounce-back Date: 24 Oct 95 00:22:59 GMT Approved: fjh@cs.mu.oz.au From: Alan Griffiths <aGriffiths@ma.ccngroup.com> Newsgroups: comp.std.c++ Subject: relaxing const match on function implementation X-Original-Date: Mon, 23 Oct 95 12:41:47 GMT Organization: CCN Market Analysis Message-ID: <814452107snz@ma.ccngroup.com> Reply-To: aGriffiths@ma.ccngroup.com X-Newsreader: Demon Internet Simple News v1.30 X-Auth: PGPMoose V1.1 PGP comp.std.c++ iQBFAgUBMIwx7+EDnX0m9pzZAQEgeAF/XNrzKALjNrpcqL0W1aoW2ivDZ7Y0k9i6 vd7QKItoGNNkzl+8EAJXOEH1eiul51sa =i7av