3 ms·
I'm not quite seasoned, but I recognize that this discussion regularly gets muddied because it conflates implicit parameters and implicit conversions. Implicit
by tunesmith 9y ago
I'm not quite seasoned, but I recognize that this discussion regularly gets muddied because it conflates implicit parameters and implicit conversions.
Implicit parameters are everywhere, and they're relatively simple to understand once you get past the mental block that your variables might not actually be declared in the file of code you are viewing. Your mental model just has to include what that file imports, and then you can pretty much understand what implicit parameters are doing. Implicit parameters are useful for a basic form of dependency injection, and they're one of the basic prerequisites for when you are using actors or futures.
Implicit conversions are something else - I wouldn't use them just to be clever.
But once you get into things like typeclasses (which are easier to understand in Haskell for some reason), implicits become important. So if you have reason to use typeclasses (and there are very good reasons to use them), then implicits are valuable.
If your programming doesn't need much abstraction, then you don't really need those kinds of tools though.
- christophilus 9y agoI understand the distinction and don't like implicit parameters. Coming from Clojure, one could say that the "use" keyword shares a lot of the same pitfalls as implicit parameters, in that you are introducing values into your namespace which have not explicitly been referenced or scoped. In Clojure, I choose "require" instead of "use" because "use" introduces too much ambiguity. The "use" statement in Clojure consistently makes code harder to read (for me), and I suspect the same is true of Scala's implicit parameters. [Edit: Rails is another great example of implicit parameters run amok. Needless to say, I'm not a Rails fan.]