Want reasonable reference counting? Disable automatic sharing of immutable
tsbockman
thomas.bockman at gmail.com
Mon Nov 15 00:40:47 UTC 2021
On Sunday, 14 November 2021 at 20:04:40 UTC, H. S. Teoh wrote:
> However, it does have far-reaching implications. For example,
> it implies that refcounted objects cannot be used inside any
> type that may get passed to a const-receiving interface.
While this is a problem, it is not as extreme as you make it
sound.
Why? Because borrowing does not involve writing to the reference
count, and most functions just need access to, not ownership of,
their arguments. So `const` will often work.
Nevertheless, you still have a strong point. I think the better
option is to sacrifice `pure` in order to make transitive `const`
and `immutable` work properly with reference counting.
I can't think of any real problems this would cause; generic code
usually infers purity, anyway.
More information about the Digitalmars-d
mailing list