On Wednesday, 11 April 2018 at 14:33:06 UTC, Adam D. Ruppe wrote:
On Wednesday, 11 April 2018 at 14:26:53 UTC, ixid wrote:
Is it possible to infer a template's return type from what it's assigned to? If not is this a difficult or worthless feature to add?

Not really. The function call needs to make sense by itself:

fun(a)

needs to be a complete thing for a lot of things in the language to work. Type checking assumes it is there, inference assumes it is there, overloading assumes it s there, etc.

void foo(int);
void foo(float);

foo(fun(a)); // what happens?


So I don't say anything is impossible that isn't a paradox... but the effort level to solve all these problems would be really high for D.

I am sure there are all sorts of thorns involved but for your example a somewhat arbitrarily defined fallback hierarchy of types from most complex to most simple, with it matching the most 'simple' that it can.

Reply via email to