Discussion Thread: DIP 1035-- at system Variables--Community Review Round 2

Atila Neves atila.neves at gmail.com
Tue Mar 2 20:46:17 UTC 2021


On Monday, 1 March 2021 at 21:26:18 UTC, Paul Backus wrote:
> On Monday, 1 March 2021 at 20:55:40 UTC, Atila Neves wrote:
>> On Thursday, 25 February 2021 at 09:21:20 UTC, Mike Parker 
>> wrote:
>>> This is the discussion thread for the second round of 
>>> Community Review of DIP 1035, "@system Variables":
>>>
>>> [...]
>>
>> "pointers, arrays, and other reference types are unsafe"
>>
>> This confused me. Pointers aren't unsafe unless you got one 
>> from @system code. Could you clarify please?
>
> The language here is sloppy, but the intent is to refer to 
> pointer *types*, not pointer *values*. It should read, "pointer 
> types, dynamic array types, and other reference types are 
> unsafe."

Pointer types *can* be unsafe, if the values came from @system 
code. Otherwise they're perfectly safe. Slices (dynamic arrays) 
are slightly different because of the necessity of bounds checks. 
But deferencing a pointer is fine in @safe code - the 
possibilities are:

* it came from the GC.
* is the address of a module-level variable.
* is a scoped address on the stack.
* is null.

Am I missing a case?


More information about the Digitalmars-d mailing list