Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support function pointer in match method of URLRouter #535

Closed
wants to merge 1 commit into from
Closed

support function pointer in match method of URLRouter #535

wants to merge 1 commit into from

Conversation

extrawurst
Copy link
Contributor

this is to support the following code:

import vibe.d;

void index(HTTPServerRequest req, HTTPServerResponse res){}

shared static this()
{
    auto router = new URLRouter;
    router.match(HTTPMethod.OPTIONS,"*", &index);

    listenHTTP(new HTTPServerSettings, router);
}

without this change the compiler refuses with:

source\app.d(8): Error: function vibe.http.router.URLRouter.match (HTTPMethod method, string path, v
oid delegate(HTTPServerRequest req, HTTPServerResponse res) cb) is not callable using argument types
 (HTTPMethod, string, void function(HTTPServerRequest req, HTTPServerResponse res))

is this maybe even a compiler bug ??

@etcimon
Copy link
Contributor

etcimon commented Feb 18, 2014

is this maybe even a compiler bug ??

I think the distinction between function and delegate in D is important to know and shouldn't be implicitly converted, but this does seem more convenient. You have my vote

@s-ludwig
Copy link
Member

Hm.. forgot to submit my comment before closing the browser tab. So the compiler is behaving as designed in this case w.r.t hiding overloads defined in the base class. It's basically the same as in C++, where using HTTPRouter::match is used instead of alias as in D.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants