should destroy!false be @system?
Paul Backus
snarwin at gmail.com
Thu Feb 23 17:45:48 UTC 2023
On Thursday, 23 February 2023 at 17:01:05 UTC, Steven
Schveighoffer wrote:
> is c) reasonable? Do we need to deprecate @safe calls to
> `destroy!false` for types that have destructors?
It doesn't actually matter if you make `destroy!false` `@system`,
because the user can still call `s.__dtor` directly--and you
can't make the destructor itself `@system` if you want `S` to be
usable in `@safe` code.
The only way out of this, without significant language changes,
is to make the destructor itself idempotent. This is what
`SafeRefCounted` does:
https://github.com/dlang/phobos/blob/v2.102.1/std/typecons.d#L6953-L6954
More information about the Digitalmars-d
mailing list