Isn't `each` too much of a good thing?
H. S. Teoh
hsteoh at quickfur.ath.cx
Fri Sep 18 16:47:40 UTC 2020
On Friday, 18 September 2020 at 16:21:47 UTC, 12345swordy wrote:
> On Friday, 18 September 2020 at 15:22:58 UTC, H. S. Teoh wrote:
>> On Fri, Sep 18, 2020 at 02:55:39PM +0000, 12345swordy via
[...]
>>> By implicit I am assuming your talking about c++ here correct?
>>
>> I'm speaking in general. It applies to any language, really.
>
> Not true, other languages implement implicit conversions in
> different ways. Seriously what languages are you referring here?
[...]
Any language. Implicit conversions have a tendency of reducing
code maintainability or quality.
Here's a small sampling of issues that may be encountered:
1) Scala:
https://www.rallyhealth.com/coding/implicit-implications-part-2-implicit-conversions
Quote: "In fact, Scala has deemed that implicit conversions
are so dangerous, they require you to import
scala.language.implicitConversions to use them"
2) C++:
https://docs.microsoft.com/en-us/cpp/cpp/type-conversions-and-type-safety-modern-cpp?view=vs-2019
Quote: "However, even if your program compiles without
warnings, it still may contain code that leads to implicit type
conversions that produce incorrect results."
3) Javascript:
https://blog.acolyer.org/2015/08/04/the-good-the-bad-and-the-ugly-an-empirical-study-of-implicit-type-conversions-in-javascript/
Quote: "A small but non-negligible percentage (1.15%) of all
type coercions are potentially harmful. Future language designs
or restricted versions of JavaScript may want to forbid them."
4) SQL:
https://towardsdatascience.com/how-not-to-kill-your-sql-server-performance-with-implicit-conversion-e754ac2eb134?gi=86749251fcf1
Quote: "In order to resolve inconsistencies between data
types, SQL Server must put additional effort and consume more
resources. Thus, performance will suffer, leading to inefficient
usage of indexes and extensive usage of CPU."
5) C#:
https://netvignettes.wordpress.com/2011/04/24/implicit-conversion-operators-are-bad/
Quote: "... certain markers that indicate to me that the
coder in question is inexperienced and needs more guidance. / One
such marker is the use of implicit conversion operators on
reference types."
This is just a random sampling I got from Google. There are many
more. It also corroborates my own experience working with C, C++,
Java, and D. In spite of repeated complaints over the years, I
have to say I'm glad that Walter stuck to his guns and refused to
add implicit constructors to D. Nevertheless, D still has
implicit conversions, some of which seemed like a good idea at
the time, but eventually it leads to trouble, one prime example
being alias this. (I still use alias this, mind you, but more and
more I'm beginning to realize it's not such a good idea. It's
convenient, for sure, but leads to hard-to-understand code. Not
to mention it interacts poorly with generic code, because you can
never be 100% sure exactly what type you're getting out of it.)
--T
More information about the Digitalmars-d
mailing list