D is a general-purpose systems programming language with a C-like syntax that compiles to native code.It is statically typed and supports both automatic (garbage collected) and manual memory management.D programs are structured as modules that can be compiled separately and linked with external librariesto create native libraries or executables.
This document is the reference manual for the D Programming Language. For more information andother documents, seeThe D Language Website.
The process of compiling is divided into multiple phases. Each phase isindependent of subsequent phases. For example, the scanner is not affected bythe semantic analyzer. This separation of passes makes language tools likesyntax-directed editors relatively easy to create.
Thebyte is the fundamental unit of storage. Each byte has 8 bits and is stored at a unique address. Amemory location is a sequence of one or more bytes of the exact size required to hold a scalar type. Multiple threads can access separate memory locations without interference.
Memory locations come in three groups:
Execution of a single thread on thread-local and immutable memory locations issequentially consistent. This means the collective result of the operations is the same as if they were executed in the same order that the operations appear in the program.
A memory location can be transferred from thread-local to immutable or shared if there is only one reference to the location.
A memory location can be transferred from shared to immutable or thread-local if there is only one reference to the location.
A memory location can be temporarily transferred from shared to local if synchronization is used to prevent any other threads from accessing the memory location during the operation.
Anobject is created in the following circumstances:
An object spans a sequence of memory locations which may or may not be contiguous. Its lifetime encompasses construction, destruction, and the period in between. Each object has a type which is determined either statically or by runtime type information. The object's memory locations may include any combination of thread-local, immutable, or shared.
Objects can be composed into acomposed object. Objects that make up a composed object aresubobjects. An object that is not the subobject of another object is acomplete object. The lifetime of a subobject is always within the lifetime of the complete object to which it belongs.
An object's address is the address of the first byte of the first memory location for that object. Object addresses are distinct unless one object is nested within the other.
Integer arithmetic is performed usingtwo's complement math. Integer overflow is not checked for.
Floating point arithmetic is performed usingIEEE-754 floating point math.