4 ms·
But if the compiler doesn't enforce that types are statically determinable, there will be cases where the tool will have to show you more potential definitions
by KMag 9y ago
But if the compiler doesn't enforce that types are statically determinable, there will be cases where the tool will have to show you more potential definitions for function definitions than would be shown for a statically typed language.
Maybe good tools are able to perform some static analysis and rule out some of the methods with the same name but impossible types, but the language doesn't rule out situations where the best the tool will be able to do is show you all of the function definitions with the same name as the (dynamically dispatched) function call site you're looking at.
Let's say you have seven different type hierarchies having dynamically dispatched functions named "run", with 5 definitions in each hierarchy, for a total of 35 functions named "run". In a statically typed language, if the code compiles, it's possible to narrow down the type for a given call site to either one of the hierarchies or one definition, meaning you have to look at either 1 or 5 definitions. In a dynamically typed language, there are situations where legal code results in the tool having to throw up its hands and show you all 35 definitions.
The flip side is that if you really have a spot where you'll need to dispatch to any of the different hierarchies, then in a strong statically typed language, you'll need to either create an algebraic sum type covering all 7 hierarchies, or you'll need something like a typecase / typeswitch statement to enumerate out your possibilities.
- ubernostrum 9y agothere will be cases where the tool will have to show you more potential definitions for function definitions than would be shown for a statically typed language. And even in a statically-typed language there will be cases where the tooling can only determine fairly generic things statically. I don't see anyone advocating for abandoning static typing over that occasional limitation. Yet I do see people proposing similarly-infrequent issues as cause to abandon dynamic typing.
- jaggederest 9y agoWhen $problem happens to $language_I_prefer, it's an unavoidable difficulty that is easy to work around. When $problem happens in $language_I_dislike, it's a clear sign that the language itself is inherently broken.