4 ms·
> but you’d be more likely to just go straight to the fully-correct solution that this example is never able to reach in Python Couldn't this be done if Python
by adrian17 4y ago
> but you’d be more likely to just go straight to the fully-correct solution that this example is never able to reach in Python
Couldn't this be done if Python added C++ Concepts-like facilities? As in, something like (extremely ugly oversimplified un-pythonic pseudocode):
def slow_add(a: Any, b: Any) requires({a+b}) -> decltype(a+b):
return a + b
This is still effectively duck typed, but since the type checker
is able to typecheck `a+b`, it should be able to handle `slow_add(a, b)` given these extra hints.