Why not?
Matti Niemenmaa
see_signature at for.real.address
Sun Nov 29 01:45:19 PST 2009
Uriel wrote:
> 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.
This feature already exists, you just need to declare append and foo a
bit differently:
public Foo append(Foo obj...) {}
void foo(Foo obj...) {}
More information about the Digitalmars-d
mailing list