[Issue 9481] writeln and alias this

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Feb 8 21:48:03 PST 2013


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



--- Comment #1 from Kenji Hara <k.hara.pg at gmail.com> 2013-02-08 21:47:57 PST ---
Current behavior is consistent with class inheritance.

class B {
    override string toString()
    {
        return "I'm a B!";
    }
}
class C : B {}

void main()
{
    C c = new C();
    B b = new C();
    assert(c.toString() == "I'm a B!");
    assert(b.toString() == "I'm a B!");
}

I think that 'alias this' should work as same as normal class inheritance,
excepting 'alias this' specific cases.

When I refactored std.format, I designed such literal-like formatting (e.g.
"S1(5)") as a *fallback* form. That means: if S1 has toString method (even it
is defined in the 'alias this'ed type S2), it will be always used for the
formatting of S1 object.

So, it is an expected behavior, and there is no deviation from the design.

-- 
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