On Wednesday, 28 October 2015 at 13:56:27 UTC, Adam D. Ruppe wrote:
On Tuesday, 27 October 2015 at 14:00:07 UTC, Martin Nowak wrote:
Yikes, this is such an anti-pattern.
https://github.com/rejectedsoftware/vibe.d/issues/634

Every time I use opDispatch, I add an if(name != "popFront") constraint, at least (unless it is supposed to be forwarding). It helps with this a lot and think everyone should do it.

I would go even farther and say that one should never define opDispatch without a template constraint limiting which members can be dispatched on. It may be a bit radical but we could even go as far as outright deprecating unconstrained opDispatch.

//Okay
auto opDispatch(string member)()
if (member == "get" || isVectorSwizzle!member)
{
    //...
}

//Deprecated
auto opDispatch(string member)()
{
    //...
}

Reply via email to