On Borrow Checking
Richard (Rikki) Andrew Cattermole
richard at cattermole.co.nz
Mon May 12 15:06:09 UTC 2025
On 13/05/2025 3:03 AM, Nick Treleaven wrote:
> On Monday, 12 May 2025 at 14:58:08 UTC, Richard (Rikki) Andrew
> Cattermole wrote:
>> On 13/05/2025 2:50 AM, Nick Treleaven wrote:
>>> ```d
>>> void f(scope int[]) @nogc;
>>>
>>> void g() @nogc
>>> {
>>> f([1, 2]);
>>> }
>>>
>>> ```
>>> Remove `scope`, it no longer compiles.
>>
>> I'm aware.
>>
>> In this scenario that function would need to be made ``@trusted``.
>
>
> But what if it doesn't have a safe interface - e.g. it writes an unsafe
> value to a global? It cannot be `@trusted`.
Then strictly speaking it shouldn't be ``scope``.
Otherwise for codegen only changes, a new attribute in core.attributes
would be needed.
Of course we could always leave it as is, and accept that its pragmatic.
More information about the Digitalmars-d
mailing list