D is our last hope

Siarhei Siamashka siarhei.siamashka at gmail.com
Mon Dec 11 09:49:37 UTC 2023


On Monday, 11 December 2023 at 09:08:25 UTC, Kagamin wrote:
> On Thursday, 7 December 2023 at 19:01:26 UTC, GrimMaple wrote:
>> If you want to have a `@nogc` control in a UI framework and 
>> have callbacks/events in it, you are going to force the user 
>> of that control to use `@nogc` code.
>
> A similar problem happens when `@safe` code calls `@system` 
> callbacks.

You can have `@trusted` callbacks in this case. It's just a 
matter of adding this attribute to each function after making an 
effort to attest that the function looks bug free despite using 
dangerous language features. Whereas the actual GC code can't 
just magically become `@nogc` if it actually relies on the 
garbage collector.

> I recommend to make the callback setter to be declared 
> `@system` and then cast it to `@safe`, so if something goes 
> wrong, it's not your mistake.

I'm not sure if I understand your suggestion correctly. If 
something goes wrong because you did something fishy, then it's 
probably your mistake after all.


More information about the Digitalmars-d mailing list