How does D distnguish managed pointers from raw pointers?

IGotD- nise at nise.com
Fri Oct 4 18:30:17 UTC 2019


On Friday, 4 October 2019 at 15:03:04 UTC, Johan Engelen wrote:
> On Thursday, 3 October 2019 at 14:21:37 UTC, Andrea Fontana 
> wrote:
>>
>> In D arrays are fat pointer instead:
>>
>> int[10] my_array;
>>
>> my_array is actually a pair ptr+length.
>
> ```
> int[10] my_static_array;
> int[] my_dynamic_array;
> ```
>
> my_static_array will not be a fat pointer. Length is known at 
> compile time. Address is known at link/load time so it's also 
> not a pointer but just a normal variable (& will give you a 
> pointer to the array data).
> my_dynamic_array will be a pair for ptr+length.
>
> -Johan

What if you pass a static array to a function that expects a 
dynamic array. Will D automatically create a dynamic array from 
the static array?


More information about the Digitalmars-d-learn mailing list