On Wed, Jan 16, 2019 at 11:43:19PM +0000, John Carter via 
Digitalmars-d-announce wrote:
[...]
> Given that I have probably written a lot more C++ code in my life than
> d...
> 
> ...I do find it remarkable that I can read the d code quite easily
> without reaching for the reference manual, but to make sense of his
> C++, it sends me trawling around cppreference.com

Yes, that's one of the outstanding qualities of D, and one that I was
immensely impressed with when I perused the Phobos source code for the
first time.  After having (tried to) read glibc's source code (if you
never have, I advise you not to unless you're a jaded, hardened,
hardcore C professional -- it's *not* for the faint of heart), it was
like a breath of fresh air.  D does have its warts and dark corners, but
I think on the readability front it has scored a home run compared to
the equivalent C/C++ code.


> I find Andrei's claim that checkint with a void hook reverts to int is
> amazing, and would love to verify that at the assembly level for both
> the C++ and d implementations.

This is actually quite trivial in D.  I'm too lazy to actually check the
checkedint source code, but I'd surmise it's something as simple as:

        template CheckedInt(alias hook) {
                static if (is(typeof(hook) == void))
                        alias CheckedInt = int;
                else {
                        struct CheckedInt {
                                ... // actual CheckedInt implementation here
                        }
                }
        }

or something along these lines.  Standard D practice.  (I daren't even
try to imagine what I'd have to do to make this work in C++. After
having worked with C++ for about 2 decades or so, I don't have many good
things to say about it, nor do I expect very much from it anymore.)


T

-- 
Windows 95 was a joke, and Windows 98 was the punchline.

Reply via email to