Use of Pointers with Arrays

Pointers are risky

The compiler and the D runtime environment cannot guarantee that the pointers are always used correctly. It is the programmer’s responsibility to ensure that a pointer is either null or points at a valid memory location (at a variable, an element of an array, etc.).

Therefore, it is always better to consider higher-level features of D before thinking about using pointers.

The element one past the end of an array

It is valid to point at the imaginary element one past the end of an array.

This is a useful idiom similar to number ranges. When defining a slice with a number range, the second index is one past the elements of the slice:

Get hands-on with 1000+ tech skills courses.