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

Steven Schveighoffer schveiguy at gmail.com
Thu Jun 23 14:08:15 UTC 2022


On 6/23/22 8:01 AM, Dukc wrote:
> On Thursday, 23 June 2022 at 00:37:24 UTC, Steven Schveighoffer wrote:
>>
>> You mean like a system function which removes the scope-ness of an 
>> array? Let me introduce you to my other thread: 
>> https://forum.dlang.org/thread/t7qd45$1lrb$1@digitalmars.com
>>
> 
> You are allowed to remove `scope` from an argument in unsafe code. It's 
> only if you escape that argument when you trigger undefined behaviour. 
> Just like you can cast away `const`, if you don't actually mutate the 
> cast variable.
> 

And what do you think a custom struct that circumvents the scopeness is 
going to do with that parameter?

To be clear, I think we're talking about something like:

```d
struct ScopeArray(T)
{
    T[] arr;
    @system void opAssign(scope T[] param)
    {
       arr = param; // escaping scope
    }
}
```

-Steve


More information about the Digitalmars-d-announce mailing list