named arguments, string interpolation, please stop.
Richard (Rikki) Andrew Cattermole
richard at cattermole.co.nz
Thu Jan 11 22:24:00 UTC 2024
On 12/01/2024 11:17 AM, Timon Gehr wrote:
> On 1/11/24 22:37, Walter Bright wrote:
>
> On 1/11/2024 1:18 PM, DrDread wrote:
>
> this is discarding the use case that you want to mark only parts
> of your codebase nogc, but enforce it'S really nogc. we do use
> some realtime threads, but the rest off the app is @gc.
>
> This subthread suggests to me that the problem with @nogc is it
> works. ...
>
> It does not work. There are two options:
>
> * Mark the function and callback |@nogc|, then GC users cannot use
> your library.
> * Mark the function and callback not |@nogc|, then |@nogc| users
> cannot use your library.
Indeed, what I want is contract invalidation.
```d
void func(void delegate() @safe @nogc del) @safe @nogc {
del();
}
```
If we pass in ``@nogc`` delegate, it works as is.
If we don't the caller sees:
```d
void func(void delegate() @system del) @system {
del();
}
```
It's ``@system`` simply because the delegate is not ``scope`` and
therefore can escape, otherwise with DIP1000 and ``scope`` would still
be ``@safe``.
This would not replace attribute inference. But instead help interfacing
code that needs those guarantees versus those that don't.
More information about the Digitalmars-d
mailing list