http://d.puremagic.com/issues/show_bug.cgi?id=1528


[email protected] changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |[email protected]


--- Comment #14 from [email protected] 2013-02-27 04:39:08 PST ---
(In reply to comment #13)
> I have implemented it in accordance with TDPL, and the following behaviour
> results:
> 
> // vs deduced parameter + template constraint (2)
> int f6(int a) { return 1; }
> int f6(T)(T b) if (is(T : int)) { return 2; }
> 
> void main(){
>     static assert(f6(1)==1);
>     static assert(f6(1L)==1);
> }

How does that work though, because here, you statically know that 1L will fit
in your int. But what about:

static assert(f6(1L) == 1);
static assert(f6(ulong.max) == 2); // (a) ???

ulong ul = runtime();
static assert(f6(ul) == 2);        // (b) ???

How would these resolve?

I am not really comfortable with the fact that a call can statically resolve to
two different functions depending on the static information of the *value* of a
parameter:

int f7(ubyte a) { return 1; }
int f7(T)(T b) if (is(T : int)) { return 2; }

void main(){
    static assert(f6(200u)==1); //Calls first
    static assert(f6(400u)==2); //Calls second (!?)

    //Run-time variable with TDPL-like range knowledge
    uint a = 400;
    static assert(f6(a) == 2); //Calls second  ?
    a = 200;
    static assert(f6(a) == 1); //But now calls first !?
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------

Reply via email to