3 ms·
Oh, I also disliked implicit conversions a lot. I considered them a wart at some point. Made everything hard to read and reason about. Almost every other way o
by dmacvicar 12y ago
Oh, I also disliked implicit conversions a lot. I considered them a wart at some point. Made everything hard to read and reason about.
Almost every other way of "extending" a type would have worked better in practice eg. Xtend’s Extension Methods.
- frowaway001 12y agoExtension methods have mostly the same drawbacks as implicits, but none of the advantages. It's not like Scala developers didn't know extension methods before designing implicits. Instead, they tried to come up with a more useful, principled way, which also covers a lot of the stuff which is hardcoded and implemented ad-hoc in other languages (like implicit conversions in Java). In the end, I think they made the right call: - Implicit parameters are the basis for abstractions which unify the "strategy pattern" of OO languages with FP's typeclasses, - implicit classes provide extension methods, but are better in pretty much every regard (higher reusability, less error prone) and - implicit conversions cover the ad-hoc conversions everyone takes for granted, without having to hard-code these hacks into the language (e. g. don't like Java's/C#'s/... implicit convert-everything-to-String conversion? Don't import it in Scala).