Better branding of -betterC
Steven Schveighoffer
schveiguy at gmail.com
Fri Oct 30 14:24:43 UTC 2020
On 10/30/20 5:32 AM, Ola Fosheim Grøstad wrote:
> On Friday, 30 October 2020 at 08:39:17 UTC, Paulo Pinto wrote:
>> Regarding C++, it does have one as part of C++11 GC API, C++/CLI,
>> C++/CX and Unreal C++.
>
> There are some definitions in the standard library for a tracing GC in
> C++. What I meant was that atomic_shared_ptr might qualify as automatic
> reference counting since you don't have to do explicit acquire/release.
> Even though most people don't think that C++ has automatic reference
> counting. Swift has some optimization of it though.
>
Yes, swift builds on top of Objective-C ARC. Pairs of RC increment and
decrements are elided because the compiler knows what it means. And
Swift no longer has to deal with auto release pools as the compiler is
smarter about return values.
I think D was looking at one point to be able to do this, but via a
specialized library hook.
The difference between RC and a tracing GC is that cycles can prevent
garbage from being detected in RC, whereas tracing can find those.
Even in swift, you have a notion of weak references that get
auto-nullified when the target gets destroyed, and not properly setting
up an ownership relationship will result in items not being collected.
But certainly it's much easier than the Objective-C requirements.
-Steve
More information about the Digitalmars-d
mailing list