I really like D's syntax for lambdas and I usually write code like this

  auto v = validationLayers[].all!((layerName){
    return layerProps[].count!((layer){
return strcmp(cast(const(char*))layer.layerName, layerName) == 0;
    }) > 0;
  });

But this gives you basically 0 helpful error messages:


"Error: template breeze.graphics.context.createContext.all!((layerName)
{
return layerProps[].count!((layer)
{
return strcmp(cast(const(char*))layer.layerName, layerName) == 0;
}
) > 0;
}
).all cannot deduce function from argument types !()(const(char*)[]), candidates are: /usr/include/dmd/phobos/std/algorithm/searching.d(113,10): breeze.graphics.context.createContext.all!((layerName)
{
return layerProps[].count!((layer)
{
return strcmp(cast(const(char*))layer.layerName, layerName) == 0;
}
) > 0;
}
).all(Range)(Range range) if (isInputRange!Range && is(typeof(unaryFun!pred(range.front))))
dmd failed with exit code 1"

For example I simply forgot to import `count`, nothing in the error message is really helpful and the only way to know for sure is to rip the function apart, which is not a very fun thing to do.

You can't also rip it apart easily because in the case above I implicitly capture `layerName` in the closure for `count`.

What are you thoughts on this?



Reply via email to