home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / std / cplus / 1952 < prev    next >
Encoding:
Text File  |  1993-01-02  |  1.6 KB  |  47 lines

  1. Newsgroups: comp.std.c++
  2. Path: sparky!uunet!lpi!pkt
  3. From: pkt@lpi.liant.com (Scott Turner)
  4. Subject: Re: Argument Matching
  5. Message-ID: <1993Jan2.173809.10956@lpi.liant.com>
  6. Organization: Liant Software Corporation
  7. Distribution: usa
  8. Date: Sat, 2 Jan 1993 17:38:09 GMT
  9. Lines: 36
  10.  
  11. John (MAX) Skaller writes:
  12. > Similarly,
  13. >   f(int*);
  14. >   f(const int*);
  15. > would not both be allowed. The argument in favour of this
  16. > is that overloading is for two purposes:
  17. > A)     families of semantically equivalent operations on different types
  18. >   e.g. sin(float), sin(complex)
  19. > B)  [omitted]
  20. >              
  21. > In case (A) overloading is desirable because the associated
  22. > 'transparency' renders the program more readable and amenable
  23. > to change of the types (float->complex). 
  24. > Addition of extra overloaded functions may cause re-binding,
  25. > say sin(double) is added, but it doesnt really matter
  26. > because this doesnt affect the overall semantics.
  27.  
  28. In the cases where I've seen overloading based on const, there is a very tight
  29. semantic relationship between the overloaded functions, so tight
  30. that they would be the same function except for a difference in
  31. return type.  For example,
  32.       int & access_the_count (class S&);
  33.       const int & access_the_count (const class S&);
  34. in which the overloaded function is providing access to a concrete
  35. or abstract element of an object, and whether the element is const
  36. or not depends on whether the object is const or not.
  37. --
  38. Prescott K. Turner, Jr.
  39. Liant Software Corp. (developers of LPI languages)
  40. 959 Concord St., Framingham, MA 01701 USA    (508) 872-8700
  41. UUCP: uunet!lpi!pkt                          Internet: pkt@lpi.liant.com
  42.