Want reasonable reference counting? Disable automatic sharing of immutable
Ola Fosheim Grøstad
ola.fosheim.grostad at gmail.com
Sat Nov 13 07:07:16 UTC 2021
On Saturday, 13 November 2021 at 03:03:21 UTC, Steven
Schveighoffer wrote:
> It's like saying an OS context switch that happens in the
> middle of a pure function must somehow be valid pure code.
No, by extending the lifetime of a gc object you guarantee that
the finalizer is not executed. That means you prevent a possible
side effect from occuring, which in itself is a side effect.
Assume that the finalizer calls exit() or assert(0) or does out
of bounds indexing.
If you want truly strong purity you can only allow the function
to extend lifetimes of objects with trivial destruction.
This might be more than you wish for, so just clarify what you
want to achieve with pure.
More information about the Digitalmars-d
mailing list