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
base: master
from

Conversation

Projects
None yet
3 participants
@Extrawurst
Contributor

Extrawurst commented Feb 18, 2014

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

This comment has been minimized.

Show comment
Hide comment
@etcimon

etcimon Feb 18, 2014

Contributor

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

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

This comment has been minimized.

Show comment
Hide comment
@s-ludwig

s-ludwig Feb 18, 2014

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.

Member

s-ludwig commented Feb 18, 2014

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