Why is &array[0] @safer than array.ptr?

Dukc via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Jan 24 08:49:18 PST 2017


On Tuesday, 24 January 2017 at 12:01:35 UTC, Jonathan M Davis 
wrote:
> So, while it makes sense to say that .ptr can't be used in 
> @safe code, it really doesn't make sense to suggest &arr[0] as 
> an alternative.

That may well be. But I believe everything that can provably be 
@safe are made so even when apparently pointeless, because 
someone may find creative uses for those things. Ones the 
creators did not think of. And even if there are none now, that 
may change in the future with the language or libraries.




More information about the Digitalmars-d-learn mailing list