DIP1000: Memory Safety in a Modern System Programming Language Pt.1

Kagamin spam at here.lot
Thu Jun 23 12:14:27 UTC 2022


On Wednesday, 22 June 2022 at 20:48:13 UTC, Steven Schveighoffer 
wrote:
> Sometimes algorithms require manipulation of structure, such as 
> sorting arrays, or using linked lists, and sometimes it's nice 
> to be able to point at things on the stack, temporarily. This 
> is one of the things I was looking forward to with dip1000, 
> since it does allow pointing at the stack when it can work out 
> the details.

This works:
```
struct S
{
     int[] a;
     int[] get() return scope @safe { return a; }
     void set(return int[] b) return scope @safe
     { a=b; }
}

int[] f() @safe
{
     int[2] a;
     scope S t;
     int[] b=t.get;
     t.set=a;
     return b; //no
}
```


More information about the Digitalmars-d-announce mailing list