[Issue 9112] Uniform construction for built-in types

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Jan 13 07:08:17 PST 2013


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



--- Comment #21 from Andrej Mitrovic <andrej.mitrovich at gmail.com> 2013-01-13 07:08:11 PST ---
I just think there's a good chance that the feature could bite us in generic
code and leave us spending a lot of time debugging.

Here's a somewhat contrived example:

float sqr(int val)
{
    return val * val;
}

template Call(T...)
{
    auto Call(int arg)
    {
        alias T[0] Func;
        return Func(arg);
    }
}

template GetFunc()
{
    alias int GetFunc;
}

void main()
{
    alias Call!(GetFunc!()) square;
    square(2);  // actually calls int(2)
}

test.d(13): Error: function expected before (), not int of type int

With the pull this becomes valid code.

Maybe it's obvious in this case, but when you combine tuples, mixins, etc, it
could be hard to notice what's wrong. The way I see it, the more the line
between functions and types becomes blurred the harder it can be to track bugs.

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


More information about the Digitalmars-d-bugs mailing list