Function overloading concern
Sean Kelly
sean at f4.ca
Thu Mar 9 13:59:57 PST 2006
Sean Kelly wrote:
> Carlos Santander wrote:
>>
>> Does this work?
>>
>> import a;
>> import b;
>>
>> alias a.swap swap;
>> alias b.swap swap;
>
> It does. alias is just too darn flexible for its own good :-)
By the way, the more complex C++ examples don't work in D anyway,
because D is module-based. For example, it's more likely func would be
defined in a third module like so:
Module C:
module c;
import b; // let's say b is the default implementation
template func( T )
{
void func( inout T t1, inout T t2 )
{
swap( t1, t2 );
}
}
Main:
import a;
import c;
void main()
{
int i = 1, j = 2;
func( s, t );
}
However, this doesn't work in D even without overloading. So perhaps
it's not much of an issue here anyway.
Sean
More information about the Digitalmars-d
mailing list