home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / lang / cplus / 17852 < prev    next >
Encoding:
Text File  |  1992-12-12  |  1.7 KB  |  49 lines

  1. 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
  2. From: roger@genie.UUCP (Roger H. Scott)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: do variable names in header and source need to match
  5. Message-ID: <444@genie.UUCP>
  6. Date: 11 Dec 92 04:30:08 GMT
  7. References: <1992Dec2.201236.16404@aruba.uucp> <1992Dec3.112538.11314@unix.brighton.ac.uk>
  8. Reply-To: roger@genie.UUCP (Roger H. Scott)
  9. Organization: proCASE Corporation, Santa Clara, CA
  10. Lines: 37
  11.  
  12. In article <1992Dec3.112538.11314@unix.brighton.ac.uk> je@unix.brighton.ac.uk (John English) writes:
  13. >...
  14. >One extension to the language is the ability to use arg names given in
  15. >declarations to identify parameter ordering in calls (like Ada). For example:
  16. >
  17. >   int f (int x = 0, int y = 0, int z = 0);
  18. >   f (10, z:5);   // equivalent to f (10, 0, 5);
  19. >
  20. >Obviously if names aren't given in the declaration, you can't do this.
  21. >If they are, it would seem to make sense to use them somehow!
  22. >This doesn't imply that the names in the definition have to match.
  23.  
  24. I believe it does.  Consider the following:
  25.  
  26. extern void f(int a =0, int b =0);
  27. extern void g(int a =0, int b =0);
  28.  
  29. void g(int b, int a) { // recent C++ disallows default parameter values here
  30.     ...
  31. }
  32.  
  33. void h(int b =0, int a =0) {
  34.     ...
  35. }
  36.  
  37. ...
  38.     // what do these mean?
  39.     f(a:3);
  40.     g(a:3);
  41.     h(a:3);
  42.  
  43.  
  44. This example shows that you can have a declaration, a declaration and a
  45. definition, or only a definition, for such a function.  If you don't require
  46. the declaration formal parameter names to match those in the definition how
  47. are you going to come up with consistent, unambiguous semantics for the three
  48. calls above?
  49.