Isn't `each` too much of a good thing?
12345swordy
alexanderheistermann at gmail.com
Fri Sep 18 16:21:47 UTC 2020
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
> Digitalmars-d wrote:
>> On Thursday, 17 September 2020 at 21:03:08 UTC, H. S. Teoh
>> wrote:
>>
>> > Yeah, implicit is bad. I used to be a fan of implicit
>> > things, because of the convenience... but more and more,
>> > with more experience, I'm starting to be convinced that
>> > explicit is always better -- for readability and
>> > maintainability. Too many layers of implicit things, and the
>> > code becomes obscure, hard to read, or easy to *wrongly*
>> > read, and consequently fragile.
> [...]
>> 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?
> [...]
>> The main case for it is writing:
>>
>> T t = a;
>>
>> Instead of:
>>
>> T t = (t)a
>>
>> That the main benefit of implicit conversion that we should be
>> focusing on.
>
> Just write:
>
> auto t = T(a);
>
> Mission accomplished, no need for implicit conversion, and it's
> clear exactly what's going on.
You are making assertions that you can write:
auto t = T(a);
That is not necessarily the case.
>... future readers of the code know exactly what conversions are
>taking
> place and how.
We have a solution to that already it called comments.
> When there are too many implicit conversions,
What exactly do you mean by this? The implicit conversions that I
have in mind is that implicit conversions happen once and only
once per statement.
> the code may look better superficially, but actually it may be
> hiding inefficient implicit conversions,
What do you mean by "Inefficient" here? That sounds like an
implementation issue rather than a casting issue.
> or it may look like it's doing something but it's actually
> doing something else because of the implicit conversions.
That why comments are there for.
More information about the Digitalmars-d
mailing list