Automatic typing
Timon Gehr
timon.gehr at gmx.ch
Sun Jun 30 21:19:50 PDT 2013
On 07/01/2013 05:44 AM, JS wrote:
> On Monday, 1 July 2013 at 01:56:22 UTC, Timon Gehr wrote:
>> ...
>> The described strategy can easily result in non-termination, and which
>> template instantiations it performs can be non-obvious.
>>
>> auto foo(T)(T arg){
>> static if(is(T==int)) return 1.0;
>> else return 1;
>> }
>>
>> void main(){
>> auto x;
>> x = 1;
>> x = foo(x);
>> }
>
> Sorry,
That's fine.
> it only results in non-termination if you don't check all return
> types out of a function.
Why is this relevant? I was specifically responding to the method lined
out in the post I was answering. There have not been any other attempts
to formalize the proposal so far.
> It is a rather easy case to handle by just
> following all the return types and choosing the largest one.
That neither handles the above case in a sensible way nor is it a
solution for the general issue. (Hint: D's type system is Turing complete.)
> No big deal... any other tries?
That's not how it goes. The proposed inference method has to be
completely specified for all instances, not only for those instances
that I can be bothered to provide to you as counterexamples.
More information about the Digitalmars-d
mailing list