Truly algebraic Variant and Nullable
ag0aep6g
anonymous at example.com
Tue Dec 22 17:07:16 UTC 2020
On Tuesday, 22 December 2020 at 16:54:56 UTC, 9il wrote:
> On Tuesday, 22 December 2020 at 16:43:30 UTC, ag0aep6g wrote:
[...]
>> The issue isn't that the reference outlives the struct. It's
>> that the reference outlives a tag change of the tagged union.
>
> If I am correct Dlang doesn't provide an instrument to validate
> it, isn't it?
>
> What alternative is possible?
>
> Returning it by value isn't acceptable at least because of
> performance reasons: the first target of the library is struts
> with a lot of Mir ref-counted fields.
Mark it @system then.
>>> The docs maybe not clear enough. `trustedGet` asserts type is
>>> matched, while `get` throws an exception if the type doesn't
>>> match.
>>
>> You can't rely on an assert for @safe (unless it's
>> `assert(false);`).
>
> This is why it is the market as `trusted`. It is much more
> convenient than forcing users to wrap each access with @trusted
> lambda, which feels like masochism.
@trusted makes the exact same promise to the user as @safe.
If your method doesn't have a safe interface, don't mark it @safe
or @trusted. Mark it @system.
More information about the Digitalmars-d-announce
mailing list