new DIP47: Outlining member functions of aggregates

Andrej Mitrovic andrej.mitrovich at gmail.com
Sat Sep 7 12:05:09 PDT 2013


On 9/7/13, Walter Bright <newshound2 at digitalmars.com> wrote:
> http://wiki.dlang.org/DIP47

Am I correct to say that such member definitions will have the same
overload rules as before? Currently using UFCS has issues where
function hijacking prevention will cause errors at compile time, for
example:

-----
module a;
import b;

struct A { }
void test(A a) { }  // hides B.test!

void main()
{
    B b;

    // error: function a.test (A a) is not
    // callable using argument types (B)
    b.test();
}
-----

-----
module b;
struct B { }
void test(B b) { }
-----

I just want to ensure that the following does not issue a compiler error:

-----
module a;
import b;
struct A { void test() { } }
void A.test() { }  // outlined

void main()
{
    B b;
    b.test();  // should be ok, A.test should not hide B.test!
}
-----

-----
module b;
struct B { void test() { } }
void B.test() { }  // outlined
-----


More information about the Digitalmars-d mailing list