On Tuesday, 28 October 2014 at 02:07:23 UTC, Andrei Alexandrescu wrote:
On 10/24/14 6:05 AM, IgorStepanov wrote:
On Friday, 24 October 2014 at 06:04:24 UTC, Andrei Alexandrescu wrote:
On 10/19/14 2:00 PM, IgorStepanov wrote:
Bump.

I've made a few grammar and fluency edits to the DIP, and collected a few thoughts while doing that. Will get back on this before too long.
-- Andrei

I've seen it. Thanks!
Waiting for a comments.

Coming soon. I've been under quite a bit of pressure as of late.

Should I add chapter about method overloading with alias this: it should
work (and works) as cross-module overloading. It should imply
This implies from the DIP but hasn't written explicitly.

Interesting. I think it should work like overloading of calls in base and derived classes.

Not really. Rules which define overloading class methods doesn't describe multiple inheritance case. In single inheritance case alias this rule is similar with inheritance rule: derived overload set hides base base overload set:

struct A
{
    void foo(string)
    {
        writeln("string");
    }

    void foo(int)
    {
        writeln("int");
    }
}

struct B
{
    void foo(double)
    {
        writeln("double");
    }

    A a;
    alias a this;
}

B b;
b.foo("string"); //error
b.foo(42); //called B.foo(double), not B.a.foo(int);

The second test is not similar to inherintance rules, but this case is not relevant with multiple alias this and it is already done.

When I said "cross-module overloading", I told about case when C inherits (via alias this) A and B, both A and B have "foo" methods with different paramethers and compiler should resolve foo call:

struct A
{
    void foo(string)
    {
        writeln("string");
    }

    void foo(int)
    {
        writeln("int");
    }
}


struct B
{
    void foo(double)
    {
        writeln("double");
    }
}

struct C
{
     A a;
     B b;
     alias a this;
     alias b this;
}

C c;
c.foo("str"); // OK, c.a.foo(string)
c.foo(4.2); //OK, c.b.foo(double);
c.foo(42); //Error: c.a.foo(int) or c.b.foo(double)?

BTW, similar case with multiple inheritance via interfaces works absolutely incorrect:

interface CA
{
    final void foo(string)
    {
        writeln("string");
    }

    final void foo(int)
    {
        writeln("int");
    }
}

interface CB
{
     final void foo(double)
     {
         writeln("double");
     }
}

class CC : CA, CB
{

}

auto cc = new CC();
cc.foo("xxx"); //OK, called CA.foo(string)
cc.foo(42); //called CA.foo(int) without any warnings
cc.foo(4.2); //Error: unable to call CA.foo with double argument.

In other words, compiler choses the first base interface, uses its overload set and ignores other interfaces.

OT: Should `et\s?c\.?` be written as "etc" in English?
I thought that it should be written as "et c.", because "et cetera". Or
is it an anachronism?

You can't go wrong with M-W: http://www.merriam-webster.com/dictionary/etc

Thanks.

Reply via email to