|
|
|
|
|
by yters
2881 days ago
|
|
It'd be better expressed as: def a_func(input):
if eval(input) == 0:
return 1
else:
return "Nope"
To convert this to a statically typed program, the compiler has to determine what eval(input) returns at compile time, so it knows whether the function has a type signature of int or String.In general, this is impossible, since eval(input) may not halt. |
|
And assuming that "eval" is typed as String -> Any, there should be no problem automatically inferring the type signature of this function. I certainly didn't have to solve the halting problem to generate that signature.