novehrady discussions

Matthias Ettrich ettrich@trolltech.com
Fri, 29 Aug 2003 17:57:29 +0200


On Friday 29 August 2003 12:00, Waldo Bastian wrote:
>
> DCOP allows overloading but it is cumbersome in combination with scripting
> languages that don't have strong typing. Life is easier without
> overloading.
>

Even then the second argument remains: having the argument types mangled into 
the function name allows to lookup a method and check the types at the same 
time. 

But I'm not sure I agree with Waldo. Scripting languages have dynamic types, 
and overloads are a static way of expressing similar things in a C++ 
interface without creating dynamic code (like e.g. using a variant).

Imagine an interface with two overloads:

 setValue(string)
 setValue(int)

The script could just pick the first one (or the second one) and it wouldn't 
matter. An interpreter typically has no problems casting back and forth 
between int and string.

Overloads are also very useful to express default arguments. A script 
interpreter should have no problems picking the right function from the dbus 
interface based on the number of arguments, even if it does not support 
overloads itself, only calls with a variable number of arguments.


Matthias