Want reasonable reference counting? Disable automatic sharing of immutable
Steven Schveighoffer
schveiguy at gmail.com
Fri Nov 12 23:50:15 UTC 2021
On 11/12/21 6:32 PM, Ola Fosheim Grøstad wrote:
> On Friday, 12 November 2021 at 23:07:02 UTC, Steven Schveighoffer wrote:
>> The problem is of course that this is not pure. As long as you don't
>> need pure reference counting, it's a possible solution.
>>
>> If you do need pure reference counting, this mechanism *cannot* be
>> used, even if it's not technically accessing a global. I don't care
>> what tricks you want to pull, the optimizer is going to bite you for it.
>
> Not if it is built in. Anyway, you can just require all functions to
> take the counter table as a parameter, by rewriting rules, that makes it
> pure even when it isn't builin.
That means every pure function must be passed the global table as a
parameter *just in case* there are some reference-counting things to do,
and that means that no pure function can be strong-pure. Might as well
not have pure functions in that case.
>> I'm skeptical that even normal optimizations outside of pure won't
>> bite you on this either.
>
> If it is builtin then optimizations cannot be a concern?
As I said, I'm skeptical, I'm not sure if some optimization somewhere
isn't going to make hay with our cleverness. We have smart people
working on the compilers, so I'll leave the judgment up to them.
-Steve
More information about the Digitalmars-d
mailing list