home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!zaphod.mps.ohio-state.edu!cs.utexas.edu!swrinde!emory!europa.asd.contel.com!awds.imsd.contel.com!wlbr!voder!genie!roger
- From: roger@genie.UUCP (Roger H. Scott)
- Newsgroups: comp.lang.c++
- Subject: Re: do variable names in header and source need to match
- Message-ID: <444@genie.UUCP>
- Date: 11 Dec 92 04:30:08 GMT
- References: <1992Dec2.201236.16404@aruba.uucp> <1992Dec3.112538.11314@unix.brighton.ac.uk>
- Reply-To: roger@genie.UUCP (Roger H. Scott)
- Organization: proCASE Corporation, Santa Clara, CA
- Lines: 37
-
- In article <1992Dec3.112538.11314@unix.brighton.ac.uk> je@unix.brighton.ac.uk (John English) writes:
- >...
- >One extension to the language is the ability to use arg names given in
- >declarations to identify parameter ordering in calls (like Ada). For example:
- >
- > int f (int x = 0, int y = 0, int z = 0);
- > f (10, z:5); // equivalent to f (10, 0, 5);
- >
- >Obviously if names aren't given in the declaration, you can't do this.
- >If they are, it would seem to make sense to use them somehow!
- >This doesn't imply that the names in the definition have to match.
-
- I believe it does. Consider the following:
-
- extern void f(int a =0, int b =0);
- extern void g(int a =0, int b =0);
-
- void g(int b, int a) { // recent C++ disallows default parameter values here
- ...
- }
-
- void h(int b =0, int a =0) {
- ...
- }
-
- ...
- // what do these mean?
- f(a:3);
- g(a:3);
- h(a:3);
-
-
- This example shows that you can have a declaration, a declaration and a
- definition, or only a definition, for such a function. If you don't require
- the declaration formal parameter names to match those in the definition how
- are you going to come up with consistent, unambiguous semantics for the three
- calls above?
-