4 ms·
Can’t you solve this particular issue with extension methods the way Kotlin and C# do?
by fiddlerwoaroof 4y ago
Can’t you solve this particular issue with extension methods the way Kotlin and C# do?
- sirwhinesalot 4y agoExtension methods rely on overloading, they don't use dynamic dispatch.
- fiddlerwoaroof 4y agoYeah, but typically in these languages operators don’t really need dynamic dispatch. (Although, I agree this causes surprising results).
- sirwhinesalot 4y agoC# and friends dispatch operators through overloading on static types. Extension methods rely on the same mechanism. A dynamic language like Wren cannot use such a mechanism. The author already pointed out the options: the current OO-style dispatch, Python-style "if the operator is missing, try the reverse direction", or multimethods like Julia (which are quite complex and heavyweight).