On Thursday, 6 April 2017 at 18:45:26 UTC, Ali Çehreli wrote:
On 04/06/2017 11:37 AM, Russel Winder via Digitalmars-d-learn wrote:
[...]

I think it's just a design choice. C implicitly converts the name of the function to a pointer to that function. D requires the explicit & operator:

alias Func = int function(int);

int foo(int i) {
    return i;
}

void main() {
    Func[] funcs = [ &foo ];
}

Close to what you mentioned, name of the function can be used as an alias template parameter:

void bar(alias func)() {
    func(42);
}

int foo(int i) {
    return i;
}

void main() {
    bar!foo();
}

Ali

Main reason is probably UFCS.

Reply via email to