DIP1000 observation

Dennis dkorpel at gmail.com
Mon Aug 26 18:39:54 UTC 2024


On Monday, 26 August 2024 at 10:56:06 UTC, Jonathan M Davis wrote:
> and if I mark up any code as scope to make the compiler happy, 
> that quickly becomes viral, whereas right now, I can just take 
> the address of a local and happily pass it around without any 
> complaints. I just have to mark the function as @trusted
> (...)
> But using DIP 1000 means that scope has to be used all over the 
> place.

No need! Even with dip1000, you can pass scope values to 
non-scope parameters in `@system` or `@trusted` functions:

```D
void f(char[] str) @safe; // parameter `str` is not marked `scope`

void g() @trusted // checking stack pointer lifetimes manually 
here
{
     char[32] str;
     f(str[]);
}
```

The scopeness of `str[]` ends then and there, no viral 
application of `scope` needed.


More information about the Digitalmars-d mailing list