Want reasonable reference counting? Disable automatic sharing of immutable
Stanislav Blinov
stanislav.blinov at gmail.com
Sat Nov 13 04:36:52 UTC 2021
On Saturday, 13 November 2021 at 03:03:21 UTC, Steven
Schveighoffer wrote:
> This is an odd way to look at it. The finalizers are not run
> directly, and maybe not even run on the same thread as the pure
> function being run. They also should not be observable (for the
> most part), because you should not have access to that data any
> more.
>
> It's like saying an OS context switch that happens in the
> middle of a pure function must somehow be valid pure code.
>
> -Steve
Not run directly??? As far as I know, GC, on allocation, may
hijack the caller to do a collection. Net effect is that it
executes arbitrary (not pure, not @safe, etc.) code within
caller. Caller is marked pure. GC may run impure finalizers that
mutate some global state. Something as stupid as call to "close"
which may set errno, or, I don't know, freeing half of program
state, mutating shared globals... There can be no "for the most
part" here. You've got pure function mutating global state.
That's something pure functions aren't supposed to be doing.
Unless that changed and GC isn't doing that anymore, that's a bug
that's been open for some years now.
More information about the Digitalmars-d
mailing list