Topic: idea for resolving the problems with multiple overloads


Author: mi@starlab.UUCP (Michael Hoennig)
Date: 13 Jul 92 07:28:50 GMT
Raw View
Hi world,

what do you think on this idea:

 If there ara more than one overloads of a Function or operator the
 compiler is allowed to select one randomly.

 Limitation: The overloads are separated into groups:
  1 - don't need any conversion
  2 - needs only simple conversion
  3 - needs a user defined conversion
 If there is exactly one overload in group 1 - it must be taken. If
 there are more than one - one (randomly) of them must be taken.
 If not, but there is exacly one in group 2 - ...

For example:

class AnotherThing;

class SomeThing
{
public:
 SomeThing( const AnotherThing & ); // (1)
 ...
};

class AnotherThing
{
public:
 ...
 operator SomeThing (); // (2)
};

int main()
{
 AnotherThing aThing;
 Function( aThing ); // might call (1) or (2)
      // but in both cases it will result in the
      // same object because the programmer both times
      // does (externaly) the same.
 ...
};

If there is more than one way to do some functionality the programmer must
ensure, each way does its job. Possibly the computation of the resulst
differs - but never the result!

This would be a easy coding rule. And it is very easy to test! It is at
all a back-to-back test.

Each implementor of a class must only see his own implementation. If he things
something must be done - he does it without to have thinks about, if the
implementors (designes) of the other classes/methods had done this. It is
also possible for this tho exchange easily (of cause by source) one special
implementation/design with another.

Adios
--
Michael Hoennig                                  FAX:   +49 40 230 859
StarDivision (StarLab HH)                        Phone: +49 40 230 856
Heidenkampsweg 44                                uucp: ...!unido!starlab!mi
D-W-2000 Hamburg 1                               domain: mi@starlab.uucp