Would you pay for GC?

Paulo Pinto pjmlp at progtools.org
Tue Jan 25 10:56:50 UTC 2022


On Tuesday, 25 January 2022 at 09:58:14 UTC, Ola Fosheim Grøstad 
wrote:
> On Tuesday, 25 January 2022 at 09:42:25 UTC, Araq wrote:
>> Only if you take the "deferred" RC route, which 
>> Swift/Rust/C++/Nim do not!
>
> What do you mean by "deferred"? RC increment when taking a 
> reference from the heap, but not when the reference is taken 
> from the stack + periodic stack scanning?
>
> Actually, in C++ (and to some extent in Objective-C) you 
> minimize reference counting by using programmer knowledge. You 
> increment when you take it from the heap and from thereon you 
> use a borrowed (raw) pointer down the call tree.
>
> ...

Pity that programmer knowledge can't do much to ABI requirements.

http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1116r0.pdf

Also that trick only works in single developer code bases, good 
luck not introducing a memory corruption some months/years down 
the line.

My experience with COM proves that is generally what happens when 
one decides to be smart about manually optimizing AddRef/Release 
calls.


More information about the Digitalmars-d mailing list