Why not?
Uriel
uriel at inbox.ru
Sun Nov 29 00:28:18 PST 2009
Lets consider following code:
class Foo {
private Foo[] m_SomeData;
public this(int a, double b, string c) {}
public Foo append(Foo obj) {
m_SomeData ~= obj;
return this;
}
}
void foo(Foo obj) {}
void main() {
foo(1, 1.0, "1");
Foo obj = new Foo();
obj.append(1, 1.0, "1").append(2, 2.0, "2");
}
Why not to do implicitly cast of these three parameters to new Foo
object. We know that bar should recieve a Foo object and we have a call
with parameters which exactly match one of Foo's constructors. It could
be a nice syntactic sugar though not very hard to implement I think.
More information about the Digitalmars-d
mailing list