2.8.1 Identifier Names and Keywords

D identifier names are composed of uppercase and lowercase letters, digits, and underscores, where the first character must be a letter or underscore. All identifier names beginning with an underscore (_) are reserved for use by the D system libraries. You should avoid using these names in your D programs. By convention, D programmers typically use mixed-case names for variables and all uppercase names for constants.

D language keywords are special identifiers that are reserved for use in the programming language syntax itself. These names are always specified in lowercase and must not be used for the names of D variables. The following table lists the keywords that are reserved for use by the D language.

Table 2.2 D Keywords

auto*

do*

if*

register*

string+

unsigned

break*

double

import*+

restrict*

stringof+

void

case*

else*

inline

return*

struct

volatile

char

enum

int

self+

switch*

while*

const

extern

long

short

this+

xlate+

continue*

float

offsetof+

signed

translator+

 

counter*+

for*

probe*+

sizeof

typedef

 

default*

goto*

provider*+

static*

union

 

D reserves for use as keywords a superset of the ANSI C keywords. The keywords reserved for future use by the D language are marked with “*”. The D compiler produces a syntax error if you attempt to use a keyword that is reserved for future use. The keywords that are defined by D but not defined by ANSI C are marked with “+”. D provides the complete set of types and operators found in ANSI C. The major difference in D programming is the absence of control-flow constructs. Note that keywords associated with control-flow in ANSI C are reserved for future use in D.