RFC: scope and borrowing
Walter Bright via Digitalmars-d
digitalmars-d at puremagic.com
Tue Sep 23 02:45:39 PDT 2014
On 9/22/2014 4:20 AM, Manu via Digitalmars-d wrote:
> On 22 September 2014 13:19, Walter Bright via Digitalmars-d
> <digitalmars-d at puremagic.com <mailto:digitalmars-d at puremagic.com>> wrote:
>
> On 9/21/2014 4:27 AM, Manu via Digitalmars-d wrote:
>
> It's also extremely hard to unittest; explodes the number of static if paths
> exponentially. I'm constantly finding bugs appear a year after writing
> some code
> because I missed some static branch paths when originally authoring.
>
>
> If you throw -cov while running unittests, it'll give you a report on which
> code was executed and which wasn't. Very simple and useful.
>
>
> It is a useful tool, but you can see how going to great lengths to write this
> explosion of paths is a massive pain in the first place, let alone additional
> overhead to comprehensively test that it works... it should never have been a
> problem to start with.
There are two separate issues here - the first is knowing whether or not the
code is unittested. -cov solves that issue. The second is having the multiple
code paths in the first place.
Have you tried auto ref?
I don't really know what the code you show is supposed to do from a high level.
My first impression is you are trying to write it like you'd write C++ code.
Perhaps there's a more D idiomatic way of doing it that doesn't lead to the
tangle you've got.
BTW, ref (as you know) is part of the type in C++. However, I can vouch for it
being a special case everywhere in C++, and is a horrifying quagmire of strange
edge cases. That's why it's not part of the type in D.
More information about the Digitalmars-d
mailing list