A better way to deal with overloading?

Jesse Phillips via Digitalmars-d digitalmars-d at puremagic.com
Fri Jan 27 11:32:29 PST 2017


On Thursday, 26 January 2017 at 00:02:03 UTC, Profile Anaysis 
wrote:
> Many times we pass compound types(non-primitives) as arguments 
> to functions.

I don't understand what issue you are solving. I see an undefined 
syntax:

foo(|a,b,|c1,c2,3||,|e|,|f,g,c|)

To replace an existing syntax:

foo(T1(a,b,new X(c1,c2,c3)),T2(e),T3(f,g,c));

The primary difference I'm seeing is that the undefined syntax 
doesn't specify what type is being created. To this end the one 
time I recall desiring this is when using std.variant:

void foo(Variant v) { ... }

'foo' will now take anything, but I can't call it with anything, 
instead I must call:

foo(Variant(3));

or

foo(Algebraic!(int, string, float)("hello"))

But this is a very special type.


More information about the Digitalmars-d mailing list