Can you fix this code to avoid using pointers?

H. S. Teoh via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Mar 13 07:47:20 PDT 2017


On Sat, Mar 11, 2017 at 08:07:39PM +0000, XavierAP via Digitalmars-d-learn wrote:
[...]
> I realized that the code that sparked the question made no sense and
> should be done in a different way... As is always the case when these
> questions come up.
> But I still like the version with pointers ;)

There's nothing wrong with using pointers in D.  The fact that D
alleviates most cases of (explicit) pointers is a testament to just how
awesome it is. ;-)  But that shouldn't deter anyone from using
(explicit) pointers once in a while.  In fact, D makes it such that it's
a lot safer using pointers than in C/C++, mainly because it alleviates
most of the dangerous use cases for pointers so what's left is generally
harmless stuff. Unless your code for whatever reason is involved in
heavy pointer hackery (like OS writing), but that's not a typical use
case.


T


-- 
All problems are easy in retrospect.


More information about the Digitalmars-d-learn mailing list