Templates considered impressive

H. S. Teoh hsteoh at qfbox.info
Tue Oct 1 17:30:20 UTC 2024


On Tue, Oct 01, 2024 at 04:30:27PM +0000, Salih Dincer via Digitalmars-d-learn wrote:
[...]
> > ```
> Please add this to your MyCon structure:
> ```d
> alias value this;
> // assert(num1 == 3.14);
> ```
> And test it like this too, I think it's awesome!
[...]

IMO it's not a good idea to recommend the use of `alias this`.  It's a
neat trick that solves the short-term problem, but in the long term it
actually becomes a maintenance burden.  I would recommend instead
avoiding such tricks that save a bit of typing in the short-term but
causes problems down the road.  (I used to love using `alias this`, but
over time have become convinced that it's not worth it.  It makes code
needlessly obscure and reduces understandability.)


T

-- 
The trouble with TCP jokes is that it's like hearing the same joke over and over.


More information about the Digitalmars-d-learn mailing list