On Sunday, 6 April 2014 at 01:26:21 UTC, Nick Sabalausky wrote:
Such a big mess for such a trivially simple API:

    func( [optionalFoo], [optionalBar] )

It would be *fantastic* if D recognized the disambiguation of using incompatible types and permitted this:

    interface Foo {}
    interface Bar {}
    class FooBar : Foo, Bar {}

    void func(Foo foo=someFoo, Bar bar=someBar) {...}

    func(myFoo); // Unambiguous, OK
    func(myBar); // Unambiguous, OK
    func(myFooBar); // Ambiguous, ERROR

Wouldn't it be better to have named parameters like in Python or
C#? That way you could call the function like:

func(foo=myFoo) or func(bar=myBar) or func(foo=myFoo, bar=myBar)
and there would be no ambiguity.

Reply via email to