Discussion Thread: DIP 1040--Copying, Moving, and Forwarding--Community Review Round 1

H. S. Teoh hsteoh at quickfur.ath.cx
Tue Mar 16 16:08:46 UTC 2021


On Tue, Mar 16, 2021 at 03:18:49PM +0000, bachmeier via Digitalmars-d wrote:
> On Monday, 15 March 2021 at 17:18:19 UTC, H. S. Teoh wrote:
> 
> > Although there are definitely cases for which it's actually useful,
> > the problems it brings along make it of questionable value as a
> > general language feature.  I'd also be in favor of getting rid of
> > it, at least from classes, if not completely. (The latter is
> > probably impossible; quite a lot of my own code relies on it, and I
> > imagine I'm not the only one using it among the users of D.)
> 
> A feature that can't be used wrong isn't much of a feature. alias this
> is easy to use correctly and provides immense value. The removal of
> useful features is not a good solution to bad program design.

I used to have your stance.  But these days, I'm starting to realize
more and more that implicit conversions are almost always a bad idea.
They are convenient and fast in the beginning when you're trying to get
the job done, but in the long term, they hurt readability and
maintainability.  I've come to realize that when the code relies too
much on this kind of implicit conversion, esp. via alias this, it's
often a sign of poor code structure. It's a code smell.  It works, but
smells bad, and eventually you realize that it *is* bad.


T

-- 
Talk is cheap. Whining is actually free. -- Lars Wirzenius


More information about the Digitalmars-d mailing list