On Tue, 21 Dec 2010 19:46:11 +0100, Andrej Mitrovic <[email protected]> wrote:

Hmm.. if we get uniform function call syntax for all types, perhaps
this code might even work some day:

import std.stdio;
import std.conv;

string toString(A)(A a)
{
    return to!string(a);
}

class A
{
    string name;
    this(string name)
    {
        this.name = name;
    }
    string writeTo()
    {
        return name;
    }
}

void main()
{
    auto foo = new A("I'm foo! ");
    writeln(foo.toString);  // using uniform function call syntax
}

Right now this code will compile but it will use Object's toString
instead of the one we defined above.

It would still use Object's toString, as member functions would be
tested for first.

--
Simen

Reply via email to