DIP74 - where is at?

Manu via Digitalmars-d digitalmars-d at puremagic.com
Sun Oct 11 16:08:45 PDT 2015


On 12 Oct 2015 7:31 am, "Jonathan M Davis via Digitalmars-d" <
digitalmars-d at puremagic.com> wrote:
>
> On Sunday, 11 October 2015 at 07:55:08 UTC, Manu wrote:
>>
>> Sure. If you don't care, I'm sure it's fine. But I don't feel it's
reasonable to say C++ has ref counting. You might as well say "C++ has
garbage collection" (which is probably actually more true than this) ;) ...
Objective-C supports ref counting.
>
>
> Reference counting is now part of C++'s standard library. They may not
have the kind of reference counting that you want, but they support
reference counting as part of the C++ standard.
>
> And certainly for my use cases, having wrapper classes like smart_ptr has
worked fantastically. Any performance hit that might be incurred be
extraneous increments and decrements is dwarfed by everything else that the
program is doing. And I think that it's pretty clear that the same is true
for a _lot_ of programs.
>
> I can certainly believe that it's not true for the kind of programs that
you write, and if we can better support those environments, great. But most
programmers don't program in a world where it normally matters whether a
couple of extra math operations are done or whether a function call is
virtual or not. It matters in certain areas of the program but not in
general. We don't want to be doing unnecessary operations, and efficiency
in other areas can have a huge impact on our programs, but I think that
it's quite clear that you live in a world that cares way more about every
little ounce of efficiency than most programmers do.
>
> So, I think that it's a huge stretch to say that C++ doesn't have
ref-counting or that it doesn't work - or even that a similar solution in D
wouldn't work. It would work for many people. If we can come up with one
that better supports your use cases, then great. As long as the cost
elsewhere isn't too high, why not? But that doesn't mean that a solution
like smart_ptr isn't a fantastic one for many of us.
>
> - Jonathan M Davis

Incidentally, I tried to use shared_ptr initially, but it took about 20
minutes before I realised I had to pass an rc pointer from a method...
Since rc is a wrapper, like you said above, you lose it as soon as you're
within a method. I then had to write an invasive rc implementation and hard
create a new rc instance from 'this', all over the place. Seriously, I
don't understand how anyone can say shared_ptr is a success. It's a massive
kludge, and it alone has me firmly convinced that rc is weak, inconvenient,
and highly complicated without language support.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20151012/e08f9e85/attachment.html>


More information about the Digitalmars-d mailing list