diff -uNr dmd-0.129/dmd/html/d/abi.html dmd-0.130/dmd/html/d/abi.html --- dmd-0.129/dmd/html/d/abi.html 2005-05-19 15:08:50.000000000 +0200 +++ dmd-0.130/dmd/html/d/abi.html 2005-08-26 11:54:10.000000000 +0200 @@ -12,9 +12,15 @@ - - + + + + + + + + + - + D Programming Language - Application Binary Interface + - - + www.digitalmars.com Home | Search | D +| Comments
-Last update Thu May 19 2005 +Last update Fri Aug 26 2005
+ + + +
+
+
+ + + + + +
+D
+Language
+Phobos
+Comparisons +
+
+Lexical
Modules
Declarations
Types
Properties
Attributes
Pragmas
Expressions
Statements
Arrays
Structs & Unions
Classes
Interfaces
Enums
Functions
Operator Overloading
Templates
Mixins
Contracts
Conditional Compilation
Handling errors
Garbage Collection
Memory Management
Floating Point
Inline Assembler
Interfacing To C
Portability Guide
Embedding D in HTML
Named Character Entities
Application Binary Interface
+
+
+

D Application Binary Interface

@@ -154,9 +215,10 @@ Passing abc to functions results in these implicit conversions:
-	void func(int array[3]);	// actually 
-	void func(int *p);		// abc[3] is converted to a pointer to the first element
-	void func(int array[]);	// abc[3] is converted to a dynamic array
+	void func(int array[3]); // actually 
+	void func(int *p);       // abc[3] is converted to a pointer
+				 // to the first element
+	void func(int array[]);	 // abc[3] is converted to a dynamic array
 	
@@ -197,15 +259,15 @@ TBD +

Feedback and Comments

- Add Add feedback and comments regarding this - page. + page.

-
-Copyright © 1999-2005 by Digital Mars, All Rights Reserved

+

-
diff -uNr dmd-0.129/dmd/html/d/acknowledgements.html dmd-0.130/dmd/html/d/acknowledgements.html --- dmd-0.129/dmd/html/d/acknowledgements.html 2005-05-19 15:08:50.000000000 +0200 +++ dmd-0.130/dmd/html/d/acknowledgements.html 2005-08-26 11:54:10.000000000 +0200 @@ -12,9 +12,15 @@ - - + + + + + + + + + - + D Programming Language - Acknowledgements + - - + www.digitalmars.com Home | Search | D +| Comments
-Last update Thu May 19 2005 +Last update Fri Aug 26 2005
+ + + +
+
+
+ + + + + +
+D
+Language
+Phobos
+Comparisons +
+
+ + · Overview
+ · D for Win32
+ · Win32 DLLs in D
+ · C .h to D Modules
+ · FAQ
+ · Style Guide
+ · Example: wc
+ · Future
+ · D Change Log
+ · Tech Tips
+ · Glossary
+ · Acknowledgements
+
+ Tools +
+ · DMD D Compiler
+ · GDC D Compiler
+ · Linker
+ · Profiler
+
+ Community +
+ · News Digest
+ · News
+ · Forum
+ · Announcements
+ · Learn
+ · D links
+
+ Archives +
+ · digitalmars.D
+ · digitalmars.D.dtl
+ · digitalmars.D.announce
+ · digitalmars.D.learn
+ · digitalmars.D.bugs
+ · D.gnu
+ · Old D
+
+
+
+

Acknowledgements

@@ -73,15 +143,15 @@ Matthew Wilson, Peter Zatloukal +

Feedback and Comments

- Add Add feedback and comments regarding this - page. + page.

-
-Copyright © 1999-2005 by Digital Mars, All Rights Reserved

+

-
diff -uNr dmd-0.129/dmd/html/d/arrays.html dmd-0.130/dmd/html/d/arrays.html --- dmd-0.129/dmd/html/d/arrays.html 2005-06-02 01:51:26.000000000 +0200 +++ dmd-0.130/dmd/html/d/arrays.html 2005-08-26 11:54:10.000000000 +0200 @@ -12,9 +12,15 @@ - - + + + + + + + + + - + D Programming Language - Arrays + - - + www.digitalmars.com Home | Search | D +| Comments
-Last update Thu Jun 02 2005 +Last update Fri Aug 26 2005
+ + + +
+
+
+ + + + + +
+D
+Language
+Phobos
+Comparisons +
+
+Lexical
Modules
Declarations
Types
Properties
Attributes
Pragmas
Expressions
Statements
Arrays
Structs & Unions
Classes
Interfaces
Enums
Functions
Operator Overloading
Templates
Mixins
Contracts
Conditional Compilation
Handling errors
Garbage Collection
Memory Management
Floating Point
Inline Assembler
Interfacing To C
Portability Guide
Embedding D in HTML
Named Character Entities
Application Binary Interface
+
+
+

Arrays

@@ -57,11 +118,9 @@

Pointers

-

-
-

+	
 	int* p;
-	

+ These are simple pointers to data, analogous to C pointers. Pointers are provided for interfacing with C and for @@ -75,11 +134,9 @@

Static Arrays

-

-
-

+	
 	int[3] s;
-	

+ These are analogous to C arrays. Static arrays are distinguished by having a length fixed at compile time. @@ -90,11 +147,9 @@

Dynamic Arrays

-

-
-

+	
 	int[] a;
-	

+ Dynamic arrays consist of a length and a pointer to the array data. Multiple dynamic arrays can share all or parts of the array data. @@ -110,15 +165,13 @@ Prefix declarations appear before the identifier being declared and read right to left, so: -

-
-

+	
 	int[] a;	// dynamic array of ints
 	int[4][3] b;	// array of 3 arrays of 4 ints each
 	int[][5] c;	// array of 5 dynamic arrays of ints.
 	int*[]*[3] d;	// array of 3 pointers to dynamic arrays of pointers to ints
 	int[]* e;	// pointer to dynamic array of ints
-	

+

Postfix Array Declarations

@@ -127,9 +180,7 @@ declared and read left to right. Each group lists equivalent declarations: -

-
-

+	
 	// dynamic array of ints
 	int[] a;
 	int a[];
@@ -152,7 +203,7 @@
 	// pointer to dynamic array of ints
 	int[]* e;
 	int (*e[]);
-	

+ Rationale: The postfix form matches the way arrays are declared in C and C++, and supporting this form provides an @@ -170,9 +221,7 @@ The handle to an array is specified by naming the array, as in p, s or a: -

-
-

+    
 	int* p;
 	int[3] s;
 	int[] a;
@@ -192,7 +241,7 @@
 			to by p is unknown
 	a = s;		a is initialized to point to the s array
 	a = b;		a points to the same array as b does
-    

+

Slicing

@@ -201,9 +250,7 @@ reference to it. For example: -

-
-

+    
 	int[10] a;	// declare array of 10 ints
 	int[] b;
 
@@ -212,21 +259,19 @@
 	foo(b[1]);	// equivalent to foo(0)
 	a[2] = 3;
 	foo(b[1]);	// equivalent to foo(3)
-    

+ The [] is shorthand for a slice of the entire array. For example, the assignments to b: -

-
-

+    
 	int[10] a;
 	int[] b;
 
 	b = a;
 	b = a[];
 	b = a[0 .. a.length];
-    

+ are all semantically equivalent.

@@ -234,26 +279,22 @@ is not only handy for referring to parts of other arrays, but for converting pointers into bounds-checked arrays: -

-
-

+    
 	int* p;
 	int[] b = p[0..8];
-    

+ Slicing for bit arrays is only allowed if the slice's lower bound falls on a byte boundary: -

-
-

+    
 	bit[] b;
 	...
 	b[0..8];	// ok
 	b[8..16];	// ok
 	b[8..17];	// ok
 	b[1..16];	// error, lower bound is not on a byte boundary
-    

+ Misaligned bit array slices will cause an ArrayBoundsError exception to be thrown at runtime. @@ -266,9 +307,7 @@ Array copying happens when the lvalue is a slice, and the rvalue is an array of or pointer to the same type. -

-
-

+    
 	int[3] s;
 	int[3] t;
 
@@ -278,15 +317,13 @@
 	s[0..2] = t[1..3];	same as s[0] = t[1], s[1] = t[2]
 	s[0..4] = t[0..4];	error, only 3 elements in s
 	s[0..2] = t;		error, different lengths for lvalue and rvalue
-    

+ Overlapping copies are an error: -

-
-

+    
 	s[0..2] = s[1..3];	error, overlapping copy
-	s[1..3] = s[0..2];	error, overlapping copy

+ s[1..3] = s[0..2]; error, overlapping copy Disallowing overlapping makes it possible for more aggressive parallel code optimizations than possible with the serial @@ -299,24 +336,20 @@ type of the lvalue, then the lvalue's array contents are set to the rvalue. -

-
-

+    
 	int[3] s;
 	int* p;
 
 	s[] = 3;		same as s[0] = 3, s[1] = 3, s[2] = 3
 	p[0..2] = 3;		same as p[0] = 3, p[1] = 3
-    

+

Array Concatenation

The binary operator ~ is the cat operator. It is used to concatenate arrays: -

-
-

+    
 
 	int[] a;
 	int[] b;
@@ -324,16 +357,14 @@
 
 	a = b ~ c;	Create an array from the concatenation of the
 			b and c arrays
-    

+ Many languages overload the + operator to mean concatenation. This confusingly leads to, does: -

-
-

+    
 	"10" + 3
-    

+ produce the number 13 or the string "103" as the result? It isn't obvious, and the language designers wind up carefully writing rules @@ -344,21 +375,17 @@ Similarly, the ~= operator means append, as in: -

-
-

+    
 	a ~= b;		a becomes the concatenation of a and b
-    

+ Concatenation always creates a copy of its operands, even if one of the operands is a 0 length array, so: -

-
-

+    
 	a = b			a refers to b
 	a = b ~ c[0..0]		a refers to a copy of b
-    

+ @@ -369,44 +396,34 @@ In general, (a[n..m] op e) is defined as: -

-
-

+    
 	for (i = n; i < m; i++)
 	    a[i] op e;
-    

+ So, for the expression: -

-
-

+    
 	a[] = b[] + 3;
-    

+ the result is equivalent to: -

-
-

+    
 	for (i = 0; i < a.length; i++)
 	    a[i] = b[i] + 3; 
-    

+ When more than one [] operator appears in an expression, the range represented by all must match. -

-
-

+    
 	a[1..3] = b[] + 3;	error, 2 elements not same as 3 elements
-    

+

Examples:

-

-
-

+	
 	int[3] abc;			// static array of 3 ints
 	int[] def = [ 1, 2, 3 ];	// dynamic array of 3 ints
 
@@ -427,7 +444,7 @@
 		array[2];		// ok
 		*(array + 2);		// error, array is not a pointer
 	}
-	

+

Rectangular Arrays

@@ -436,11 +453,9 @@ access them via pointers to pointers resulting from "array of pointers to array" semantics. For example, the D syntax: -

-
-

+	
 	double[][] matrix;
-	

+ declares matrix as an array of pointers to arrays. (Dynamic arrays are implemented as pointers to the array data.) Since the arrays can have varying sizes (being dynamically @@ -448,20 +463,16 @@ array rows can sometimes point to each other! Fortunately, D static arrays, while using the same syntax, are implemented as a fixed rectangular layout: -

-
-

+	
 	double[3][3] matrix;
-	

+ declares a rectangular matrix with 3 rows and 3 columns, all contiguously in memory. In other languages, this would be called a multidimensional array and be declared as: -

-
-

+	
 	double matrix[3,3];
-	

+

Array Length

@@ -469,9 +480,7 @@ the variable length is implicitly declared and set to the length of the array. -

-
-

+	
 	int[4] foo;
 	int[]  bar = foo;
 	int*   p = &foo[0];
@@ -486,7 +495,7 @@
 	bar[0]+length	// 'length' is not defined, out of scope of [ ]
 
 	bar[length-1]	// retrieves last element of the array
-	

+

Array Properties

@@ -559,9 +568,7 @@

Examples: -

-
-

+    
 	p.length	error, length not known for pointer
 	s.length	compile time constant 3
 	a.length	runtime value
@@ -571,17 +578,15 @@
 			elements s into it
 	a.dup		creates an array of a.length elements, copies
 			elements of a into it
-    

+

Setting Dynamic Array Length

The .length property of a dynamic array can be set as the lvalue of an = operator: -

-
-

+	
 	array.length = 7;
-	

+ This causes the array to be reallocated in place, and the existing contents copied over to the new array. If the new array length is @@ -599,9 +604,7 @@ This means that if there is an array slice immediately following the array being resized, the resized array could overlap the slice; i.e.: -

-
-

+	
 	char[] a = new char[20];
 	char[] b = a[0..10];
 	char[] c = a[10..20];
@@ -620,7 +623,7 @@
 	a.length = 25;	// may or may not do a copy
 	a[3] = 'z';	// may or may not affect b[3] which still overlaps
 			// the old a[3]
-	

+ To guarantee copying behavior, use the .dup property to ensure a unique array that can be resized. @@ -632,9 +635,7 @@ Resizing a dynamic array is a relatively expensive operation. So, while the following method of filling an array: -

-
-

+	
 
 	int[] array;
 	while (1)
@@ -644,14 +645,12 @@
 	    array.length = array.length + 1;
 	    array[array.length - 1] = c;
 	}
-	

+ will work, it will be inefficient. A more practical approach would be to minimize the number of resizes: -

-
-

+	
 	int[] array;
 	array.length = 100;        // guess
 	for (i = 0; 1; i++)
@@ -663,7 +662,7 @@
 	     array[i] = c;
 	}
 	array.length = i;
-	

+ Picking a good initial guess is an art, but you usually can pick a value covering 99% of the cases. @@ -679,9 +678,7 @@ A program may not rely on array bounds checking happening, for example, the following program is incorrect: -

-
-

+	
 	try
 	{
 	    for (i = 0; ; i++)
@@ -693,28 +690,24 @@
 	{
 	    // terminate loop
 	}
-	

+ The loop is correctly written: -

-
-

+	
 	for (i = 0; i < array.length; i++)
 	{
 	    array[i] = 5;
 	}
-	

+ Implementation Note: Compilers should attempt to detect array bounds errors at compile time, for example: -

-
-

+	
 	int[3] foo;
 	int x = foo[3];		// error, out of bounds
-	

+ Insertion of array bounds checking code at runtime should be turned on and off @@ -743,21 +736,17 @@

Static Initialization of Static Arrays

-

-
-

+	
 	int[3] a = [ 1:2, 3 ];		// a[0] = 0, a[1] = 2, a[2] = 3
-	

+ This is most handy when the array indices are given by enums: -

-
-

+	
 	enum Color { red, blue, green };
 
 	int value[Color.max] = [ blue:6, green:2, red:5 ];
-	

+ If any members of an array are initialized, they all must be. This is to catch @@ -773,22 +762,18 @@ Bit vectors can be constructed: -

-
-

+	
 	bit[10] x;		// array of 10 bits
-	

+ The amount of storage used up is implementation dependent. Implementation Note: on Intel CPUs it would be rounded up to the next 32 bit size. -

-
-

+	
 	x.length		// 10, number of bits
 	x.size			// 4,  bytes of storage
-	

+ So, the size per element is not (x.size / x.length). @@ -806,12 +791,10 @@ just a dynamic array of characters. String literals become just an easy way to write character arrays. -

-
-

+	
 	char[] str;
 	char[] str1 = "abc";
-	

+ char[] strings are in UTF-8 format. wchar[] strings are in UTF-16 format. @@ -820,14 +803,12 @@ Strings can be copied, compared, concatenated, and appended: -

-
-

+	
 	str1 = str2;
 	if (str1 < str3) ...
 	func(str3 ~ str4);
 	str4 ~= str1;
-	

+ with the obvious semantics. Any generated temporaries get cleaned up by the garbage collector (or by using alloca()). Not only that, @@ -837,22 +818,18 @@ A pointer to a char can be generated: -

-
-

+	
 	char *p = &str[3];	// pointer to 4th element
 	char *p = str;		// pointer to 1st element
-	

+ Since strings, however, are not 0 terminated in D, when transferring a pointer to a string to C, add a terminating 0: -

-
-

+	
 	str ~= "\0";
-	

+ The type of a string is determined by the semantic phase of compilation. The type is @@ -862,11 +839,9 @@ the result is an error. To disambiguate these cases, a cast is appropriate: -

-
-

+	
 	cast(wchar [])"abc"	// this is an array of wchar characters
-	

+ String literals are implicitly converted between chars, wchars, and dchars as necessary. @@ -875,9 +850,7 @@ Strings a single character in length can also be exactly converted to a char, wchar or dchar constant: -

-
-

+	
 	char c;
 	wchar w;
 	dchar d;
@@ -888,7 +861,7 @@
 	w = "b"[0];		// w is assigned the wchar character 'b'
 	w = \r;			// w is assigned the carriage return wchar character
 	d = 'd';		// d is assigned the character 'd'
-	

+

printf() and Strings

@@ -897,21 +870,17 @@ to use printf() with D strings. The first is to add a terminating 0, and cast the result to a char*: -

-
-

+	
 	str ~= "\0";
 	printf("the string is '%s'\n", (char *)str);
-	

+ The second way is to use the precision specifier. The way D arrays are laid out, the length comes first, so the following works: -

-
-

+	
 	printf("the string is '%.*s'\n", str);
-	

+ In the future, it may be necessary to just add a new format specifier to printf() instead of relying on an implementation @@ -965,36 +934,30 @@ Associative arrays are declared by placing the KeyType within the [] of an array declaration: -

-
-

+	
 	int[char[]] b;		// associative array b of ints that are
 				// indexed by an array of characters.
 				// The KeyType is char[]
 	b["hello"] = 3;		// set value associated with key "hello" to 3
 	func(b["hello"]);	// pass 3 as parameter to func()
-	

+ Particular keys in an associative array can be removed with the remove function: -

-
-

+	
 	b.remove("hello");
-	

+ The InExpression yields a pointer to the value if the key is in the associative array, or null if not: -

-
-

+	
 	int* p;
 	p = ("hello" in b);
 	if (p != null)
 		...
-	

+ KeyTypes cannot be functions or voids.

@@ -1004,18 +967,14 @@ data within the struct value. A custom mechanism can be used by providing the following functions as struct members: -

-
-

+	
 	uint toHash();
 	int opCmp(KeyType* s);
-	

+ For example: -

-
-

+	
 	import std.string;
 
 	struct MyString
@@ -1034,7 +993,7 @@
 		return std.string.cmp(this.str, s.str);
 	    }
 	}
-	

+

Properties

@@ -1075,9 +1034,7 @@

Associative Array Example: word count

-

-
-

+    
     import std.file;		// D file I/O
 
     int main (char[][] args)
@@ -1148,17 +1105,17 @@
 	}
 	return 0;
     }
-    

+ +

Feedback and Comments

- Add Add feedback and comments regarding this - page. + page.

-
-Copyright © 1999-2005 by Digital Mars, All Rights Reserved

+

-
diff -uNr dmd-0.129/dmd/html/d/attribute.html dmd-0.130/dmd/html/d/attribute.html --- dmd-0.129/dmd/html/d/attribute.html 2005-07-23 11:41:02.000000000 +0200 +++ dmd-0.130/dmd/html/d/attribute.html 2005-08-26 11:54:10.000000000 +0200 @@ -12,9 +12,15 @@ - - + + + + + + + + + - + D Programming Language - Attributes + - - + www.digitalmars.com Home | Search | D +| Comments
-Last update Sat Jul 23 2005 +Last update Fri Aug 26 2005 +
+ + + +
+
+
+ + + + + +
+D
+Language
+Phobos
+Comparisons +

+Lexical
Modules
Declarations
Types
Properties
Attributes
Pragmas
Expressions
Statements
Arrays
Structs & Unions
Classes
Interfaces
Enums
Functions
Operator Overloading
Templates
Mixins
Contracts
Conditional Compilation
Handling errors
Garbage Collection
Memory Management
Floating Point
Inline Assembler
Interfacing To C
Portability Guide
Embedding D in HTML
Named Character Entities
Application Binary Interface
+
+
+

Attributes

-

-
-

+	
 	AttributeSpecifier:
 	    Attribute :
 	    Attribute DeclDefBlock
@@ -80,7 +139,7 @@
 	    DeclDef
 	    { }
 	    { DeclDefs }
-	

+ Attributes are a way to modify one or more declarations. The general forms are: @@ -125,9 +184,7 @@

Linkage Attribute

-

-
-

+	
 	LinkageAttribute:
 		extern
 		extern ( LinkageType )
@@ -138,7 +195,7 @@
 		D
 		Windows
 		Pascal
-	

+ D provides an easy way to call C functions and operating system API functions, as compatibility with both is essential. @@ -154,35 +211,27 @@ C function calling conventions are specified by: -

-
-

+	
 	extern (C):
 		int foo();	call foo() with C conventions
-	

+ D conventions are: -

-
-

+	
 	extern (D):
-	

+ or: -

-
-

+	
 	extern:
-	

+ Windows API conventions are: -

-
-

+	
 	extern (Windows):
 	    void *VirtualAlloc(
 	    void *lpAddress,
@@ -190,17 +239,15 @@
 	    uint flAllocationType,
 	    uint flProtect
 	    );
-	

+

Align Attribute

-

-
-

+	
 	AlignAttribute:
 		align
 		align ( Integer )
-	

+ Specifies the alignment of struct members. align by itself sets it to the default, which matches the default member alignment @@ -212,27 +259,23 @@ Matching the behavior of the companion C compiler can have some surprising results, such as the following for Digital Mars C++: -

-
-

+	
 	struct S
 	{   align(4) byte a;	// placed at offset 0
 	    align(4) byte b;	// placed at offset 1
-	}

+ } AlignAttribute is meant for C ABI compatiblity, which is not the same thing as binary compatibility across diverse platforms. For that, use packed structs: -

-
-

+	
 	align (1) struct S
 	{   byte a;	// placed at offset 0
 	    byte[3] filler1;
 	    byte b;	// placed at offset 4
 	    byte[3] filler2;
-	}

+ } A value of 1 means that no alignment is done; members are packed together. @@ -258,14 +301,12 @@ if any code refers to deprecated declarations: -

-
-

+	
 	deprecated
 	{
 		void oldFoo();
 	}
-	

+ Implementation Note: The compiler should have a switch specifying if deprecated declarations should be compiled with @@ -309,33 +350,27 @@

Const Attribute

-

-
-

+	
 	const
-	

+ The const attribute declares constants that can be evaluated at compile time. For example: -

-
-

+	
 	const int foo = 7;
 
 	const
 	{
 	    double bar = foo + 6;
 	}
-	

+ A const declaration without an initializer must be initialized in a constructor (for class fields) or in a static constructor (for static class members, or module variable declarations). -

-
-

+	
 	const int x;
 	const int y;
 
@@ -377,7 +412,7 @@
 		// error, d is not initialized
 	    }
 	}
-	

+ It is not an error to have const module variable declarations without initializers if there is no constructor. This is to support the practice @@ -387,11 +422,9 @@

Override Attribute

-

-
-

+	
 	override
-	

+ The override attribute applies to virtual functions. It means that the function must override a function with the @@ -400,9 +433,7 @@ gets its parameters changed, and all derived classes need to have their overriding functions updated. -

-
-

+	
 	class Foo
 	{
 	    int bar();
@@ -417,15 +448,13 @@
 		int abc(int x);		// ok
 	    }
 	}
-	

+

Static Attribute

-

-
-

+	
 	static
-	

+ The static attribute applies to functions and data. It means that the declaration does not apply to a particular @@ -433,9 +462,7 @@ other words, it means there is no this reference. static is ignored when applied to other declarations. -

-
-

+	
 	class Foo
 	{
 	    static int bar() { return 6; }
@@ -449,7 +476,7 @@
 	Foo.foobar();	// error, no instance of Foo
 	f.bar();	// produces 6;
 	f.foobar();	// produces 7;
-	

+ Static functions are never virtual.

@@ -462,22 +489,18 @@ to a file. Use the private attribute in D to achieve that. For example: -

-
-

+	
 	module foo;
 	int x = 3;		// x is global
 	private int y = 4;	// y is local to module foo
-	

+

Auto Attribute

-

-
-

+	
 	auto
-	

+ The auto attribute is used for local variables and for class declarations. For class declarations, the auto attribute creates @@ -523,15 +546,15 @@ they can still provide 'base class functionality.' +

Feedback and Comments

- Add Add feedback and comments regarding this - page. + page.

-
-Copyright © 1999-2005 by Digital Mars, All Rights Reserved

+

-
diff -uNr dmd-0.129/dmd/html/d/changelog.html dmd-0.130/dmd/html/d/changelog.html --- dmd-0.129/dmd/html/d/changelog.html 2005-08-06 21:59:06.000000000 +0200 +++ dmd-0.130/dmd/html/d/changelog.html 2005-09-06 16:53:26.000000000 +0200 @@ -12,9 +12,15 @@ - - + + + + + + + + + - + D Programming Language - Change Log + - - + www.digitalmars.com Home | Search | D +| Comments
-Last update Sat Aug 06 2005 +Last update Tue Sep 06 2005 +
+ + + +
+
+
+ + + + + +
+D
+Language
+Phobos
+Comparisons +

+ + · Overview
+ · D for Win32
+ · Win32 DLLs in D
+ · C .h to D Modules
+ · FAQ
+ · Style Guide
+ · Example: wc
+ · Future
+ · D Change Log
+ · Tech Tips
+ · Glossary
+ · Acknowledgements
+
+ Tools +
+ · DMD D Compiler
+ · GDC D Compiler
+ · Linker
+ · Profiler
+
+ Community +
+ · News Digest
+ · News
+ · Forum
+ · Announcements
+ · Learn
+ · D links
+
+ Archives +
+ · digitalmars.D
+ · digitalmars.D.dtl
+ · digitalmars.D.announce
+ · digitalmars.D.learn
+ · digitalmars.D.bugs
+ · D.gnu
+ · Old D
+
+
+
+

D Change Log


+

+ What's New for + D 0.130 +

+ +Sep 6, 2005 +

+ +

New/Changed Features

+
    +
  • Added Don Clugston's std.math.feqrel(). +
  • Added Ben Hinkle's updates to std.stream: + + +
  • Added Ben Hinkle's updates to std.mmfile from thread + D.bugs/4550
  • +
      +
    • added windowing support +
    • changed size parameters to ulong instead of size_t +
    • commented out the debug printf +
    • added unittests +
    • updated help +
    + +
+ +

Bugs Fixed

+ + +

What's New for D 0.129 @@ -330,7 +452,7 @@
  • .size property is no longer deprecated, it is an error. Replace with .sizeof.
  • Renamed DMD source debcond.h to cond.h, debcond.c to cond.c. -
  • Added Burton Radons' std.boxer. +
  • Added Burton Radons' std.boxer.
  • Reformatted the documentation to use a bit of color.
  • Added static if.
  • Added iftype. @@ -402,7 +524,7 @@

    New/Changed Features

      -
    • Added Ben Hinkle's fixes for std.stream: +
    • Added Ben Hinkle's fixes for std.stream:
      • fixes the seekable bugs on reading stdin and pipes
      • adds isOpen and eof to InputStream @@ -419,7 +541,7 @@
      • Fixed DMDScript build break.
      • Fixed memory corruption problem with array[length..length].
      • Fixed compiler seg fault on uplevel invariant. -
      • Fixed problem detecting circular interface heirarchies. +
      • Fixed problem detecting circular interface hierarchies.
      • Fixed cat of static arrays.
      • Fixed Internal error cg87 1240.
      • Fixed D.bugs/3710 @@ -519,8 +641,8 @@ and do constant folding on them in a precision that is greater than the precision of its type.
      • Changed AMD64 predefined version to X86_64. -
      • Added Matthew Wilson's std.openrj. -
      • Ben Hinkle submitted a new std.stream +
      • Added Matthew Wilson's std.openrj. +
      • Ben Hinkle submitted a new std.stream with:
        @@ -754,15 +876,15 @@
      • Renamed std.regexp.RegExp.search to std.regexp.RegExp.find to be analogous to names in - std.string. Old name remains as + std.string. Old name remains as a deprecated alias.
      • Added functions split, find, rfind, sub, search to - std.regexp. -
      • Added functions tr, + std.regexp. +
      • Added functions tr, succ, squeeze, removechars, countchars, inPattern, chop, - and chomp to std.string. + and chomp to std.string.
      • Incorporated Christopher E. Miller's fixes to std.socket:
        @@ -772,7 +894,7 @@ are actually regular I/O functions. Added classes Protocol and Service. Added Socket.accepting() to allow derived classes to be accepted. - Documentation and samples updated. + Documentation and samples updated. Fixed major bug in the linux version.
        @@ -2333,15 +2455,15 @@ here.
      +
  • Feedback and Comments

    - Add Add feedback and comments regarding this - page. + page.

    -
    -Copyright © 1999-2005 by Digital Mars, All Rights Reserved

    +

    -
    diff -uNr dmd-0.129/dmd/html/d/class.html dmd-0.130/dmd/html/d/class.html --- dmd-0.129/dmd/html/d/class.html 2005-06-15 11:43:06.000000000 +0200 +++ dmd-0.130/dmd/html/d/class.html 2005-08-26 11:54:10.000000000 +0200 @@ -12,9 +12,15 @@ - - + + + + + + + + + - + D Programming Language - Classes + - - + www.digitalmars.com Home | Search | D +| Comments
    -Last update Wed Jun 15 2005 +Last update Fri Aug 26 2005
    + + + +
    +
    +
    + + + + + +
    +D
    +Language
    +Phobos
    +Comparisons +
    +
    +Lexical
    Modules
    Declarations
    Types
    Properties
    Attributes
    Pragmas
    Expressions
    Statements
    Arrays
    Structs & Unions
    Classes
    Interfaces
    Enums
    Functions
    Operator Overloading
    Templates
    Mixins
    Contracts
    Conditional Compilation
    Handling errors
    Garbage Collection
    Memory Management
    Floating Point
    Inline Assembler
    Interfacing To C
    Portability Guide
    Embedding D in HTML
    Named Character Entities
    Application Binary Interface
    +
    +
    +

    Classes

    @@ -61,9 +122,7 @@ A class declaration is defined: -

    -
    -
    
    +	
     	ClassDeclaration:
     		class Identifier BaseClassListopt ClassBody
     
    @@ -109,7 +168,7 @@
     		UnitTest
     		ClassAllocator
     		ClassDeallocator
    -	

    + Classes consist of: @@ -138,33 +197,27 @@ A class is defined: -

    -
    -
    
    +	
     	class Foo
     	{
     	    ... members ...
     	}
    -	

    + Note that there is no trailing ; after the closing } of the class definition. It is also not possible to declare a variable var like: -

    -
    -
    
    +	
     	class Foo { } var;
    -	

    + Instead: -

    -
    -
    
    +	
     	class Foo { }
     	Foo var;
    -	

    +

    Fields

    @@ -194,9 +247,7 @@ type of the class, not expressions which produce the type of the field itself: -

    -
    -
    
    +	
     	class Foo
     	{
     	    int x;
    @@ -209,7 +260,7 @@
     	    o = Foo.x.offsetof;   // yields 8
     	    o = foo.x.offsetof;   // error, .offsetof an int type
     	}
    -	

    +

    Super Class

    @@ -219,12 +270,10 @@

    Constructors

    -

    -
    -
    
    +	
     	Constructor:
     		this( ParameterList ) BlockStatement
    -	

    + Members are always initialized to the default initializer for their type, which is usually 0 for integer types and @@ -236,16 +285,14 @@ there can be a static initializer to be used instead of the default: -

    -
    -
    
    +	
     	class Abc
     	{
     	    int a;	// default initializer for a is 0
     	    long b = 7;	// default initializer for b is 7
     	    float f;	// default initializer for f is NAN
     	}
    -	

    + This static initialization is done before any constructors are called. @@ -254,9 +301,7 @@ Constructors are defined with a function name of this and having no return value: -

    -
    -
    
    +	
     	class Foo
     	{
     	    this(int x)		// declare constructor for Foo
    @@ -266,14 +311,12 @@
     	    {   ...
     	    }
     	}
    -	

    + Base class construction is done by calling the base class constructor by the name super: -

    -
    -
    
    +	
     	class A { this(int y) { } }
     
     	class B : A
    @@ -286,14 +329,12 @@
     		...
     	    }
     	}
    -	

    + Constructors can also call other constructors for the same class in order to share common initializations: -

    -
    -
    
    +	
     	class C
     	{
     	    int j;
    @@ -307,7 +348,7 @@
     		j = i;
     	    }
     	}
    -	

    + If no call to constructors via this or super appear in a constructor, and the base class has a constructor, a call @@ -317,11 +358,9 @@ If there is no constructor for a class, but there is a constructor for the base class, a default constructor of the form: -

    -
    -
    
    +	
     	this() { }
    -	

    + is implicitly generated.

    @@ -331,20 +370,16 @@

    1. It is illegal for constructors to mutually call each other: -

      -
      -
      
      +	
       	this() { this(1); }
       	this(int i) { this(); }	// illegal, cyclic constructor calls
      -	

      +

    2. If any constructor call appears inside a constructor, any path through the constructor must make exactly one constructor call: -

      -
      -
      
      +	
       	this()	{ a || super(); }	// illegal
       
       	this() { this(1) || super(); }	// ok
      @@ -356,7 +391,7 @@
       		super();	// illegal, inside loop
       	    }
       	}
      -	

      +

    3. It is illegal to refer to this implicitly or explicitly prior to making a constructor call. @@ -366,11 +401,9 @@ Instances of class objects are created with NewExpressions: -

      -
      -
      
      +	
       	A a = new A(3);
      -	

      + The following steps happen: @@ -400,27 +433,23 @@

      Destructors

      -

      -
      -
      
      +	
       	Destructor:
       		~this() BlockStatement
      -	

      + The garbage collector calls the destructor function when the object is deleted. The syntax is: -

      -
      -
      
      +	
       	class Foo
       	{
       		~this()		// destructor for Foo
       		{
       		}
       	}
      -	

      + There can be only one destructor per class, the destructor does not have any parameters, @@ -462,12 +491,10 @@

      Static Constructors

      -

      -
      -
      
      +	
       	StaticConstructor:
       		static this() BlockStatement
      -	

      + A static constructor is defined as a function that performs initializations before the @@ -483,15 +510,13 @@ this stems from not having good control over exactly when the code is executed, for example: -

      -
      -
      
      +	
       	class Foo
       	{
       	    static int a = b + 1;
       	    static int b = a * 2;
       	}
      -	

      + What values do a and b end up with, what order are the initializations executed in, what @@ -511,9 +536,7 @@ initialization is performed by a static constructor, defined with a special syntax static this(). -

      -
      -
      
      +	
       	class Foo
       	{
       	    static int a;		// default initialized to 0
      @@ -526,7 +549,7 @@
       		b = a * 2;		// b is set to 4
       	    }
       	}
      -	

      + static this() is called by the startup code before main() is called. If it returns normally @@ -546,9 +569,7 @@ The static in the static constructor declaration is not an attribute, it must appear immediately before the this: -

      -
      -
      
      +	
       	class Foo
       	{
       	    static this() { ... }	// a static constructor
      @@ -560,30 +581,26 @@
       	    static:
       		this() { ... }		// not a static constructor
       	}
      -	

      +

      Static Destructor

      -

      -
      -
      
      +	
       	StaticDestructor:
       		static ~this() BlockStatement
      -	

      + A static destructor is defined as a special static function with the syntax static ~this(). -

      -
      -
      
      +	
       	class Foo
       	{
       	    static ~this()		// static destructor
       	    {
       	    }
       	}
      -	

      + A static destructor gets called on program termination, but only if the static constructor @@ -596,9 +613,7 @@ The static in the static denstructor declaration is not an attribute, it must appear immediately before the ~this: -

      -
      -
      
      +	
       	class Foo
       	{
       	    static ~this() { ... }	// a static destructor
      @@ -610,16 +625,14 @@
       	    static:
       		~this() { ... }		// not a static destructor
       	}
      -	

      +

      Class Invariants

      -

      -
      -
      
      +	
       	ClassInvariant:
       		invariant BlockStatement
      -	

      + Class invariants are used to specify characteristics of a class that always must be true (except while executing a member function). For example, a @@ -628,9 +641,7 @@ -

      -
      -
      
      +	
       	class Date
       	{
       	    int day;
      @@ -642,7 +653,7 @@
       		assert(0 <= hour && hour < 24);
       	    }
       	}
      -	

      + The class invariant is a contract saying that the asserts must hold true. @@ -657,9 +668,7 @@ Doing so will result in a stack overflow, as the invariant will wind up being called in an infinitely recursive manner. -

      -
      -
      
      +	
       	class Foo
       	{
       	    public void f() { }
      @@ -671,19 +680,17 @@
       		g();  // ok, g() is not public
       	    }
       	}
      -	

      + The invariant can be checked when a class object is the argument to an assert() expression, as: -

      -
      -
      
      +	
       	Date mydate;
       	...
       	assert(mydate);		// check that class Date invariant holds
      -	

      + If the invariant fails, it throws an InvariantException. Class invariants are inherited, that is, @@ -698,12 +705,10 @@

      Unit Tests

      -

      -
      -
      
      +	
       	UnitTest:
       		unittest BlockStatement
      -	

      + Unit tests are a series of test cases applied to a class to determine if it is working properly. Ideally, unit tests should be run every @@ -715,14 +720,12 @@ Classes can have a special member function called: -

      -
      -
      
      +	
       	unittest
       	{
       	    ...test code...
       	}
      -	

      + A compiler switch, such as -unittest for dmd, will cause the unittest test code to be compiled and incorporated into @@ -733,9 +736,7 @@ For example, given a class Sum that is used to add two values: -

      -
      -
      
      +	
       	class Sum
       	{
       	    int add(int x, int y) { return x + y; }
      @@ -747,27 +748,23 @@
       		assert(sum.add(-2,0) == -2);
       	    }
       	}
      -	

      +

      Class Allocators

      -

      -
      -
      
      +	
       	ClassAllocator:
       		new ( ParameterList ) BlockStatement
      -	

      + A class member function of the form: -

      -
      -
      
      +	
       	new(uint size)
       	{
       	    ...
       	}
      -	

      + is called a class allocator. The class allocator can have any number of parameters, provided @@ -776,11 +773,9 @@ determined by the usual function overloading rules. When a new expression: -

      -
      -
      
      +	
       	new Foo;
      -	

      + is executed, and Foo is a class that has an allocator, the allocator is called with the first argument @@ -794,9 +789,7 @@ additional arguments are specified within parentheses after the new in the NewExpression: -

      -
      -
      
      +	
       	class Foo
       	{
       	    this(char[] a) { ... }
      @@ -810,7 +803,7 @@
       	...
       
       	new(1,2) Foo(a);	// calls new(Foo.size,1,2)
      -	

      + Derived classes inherit any allocator from their base class, if one is not specified. @@ -820,34 +813,28 @@

      Class Deallocators

      -

      -
      -
      
      +	
       	ClassDeallocator:
       		delete ( ParameterList ) BlockStatement
      -	

      + A class member function of the form: -

      -
      -
      
      +	
       	delete(void *p)
       	{
       	    ...
       	}
      -	

      + is called a class deallocator. The deallocator must have exactly one parameter of type void*. Only one can be specified for a class. When a delete expression: -

      -
      -
      
      +	
       	delete f;
      -	

      + is executed, and f is a reference to a class instance that has a deallocator, the deallocator is called with a pointer to the @@ -866,11 +853,9 @@ An auto class is a class with the auto attribute, as in: -

      -
      -
      
      +	
       	auto class Foo { ... }
      -	

      + The auto characteristic is inherited, so if any classes derived from an auto class are also auto. @@ -879,9 +864,7 @@ An auto class reference can only appear as a function local variable. It must be declared as being auto: -

      -
      -
      
      +	
       	auto class Foo { ... }
       
       	void func()
      @@ -889,7 +872,7 @@
       	    Foo f;	// error, reference to auto class must be auto
       	    auto Foo g = new Foo();	// correct
       	}
      -	

      + When an auto class reference goes out of scope, the destructor (if any) for it is automatically called. This holds true even if @@ -902,9 +885,7 @@ A nested class has access to the variables and other symbols of the classes and functions it is nested inside: -

      -
      -
      
      +	
       	class Outer
       	{
       	    int m;
      @@ -929,15 +910,13 @@
       		}
       	    }
       	}
      -	

      + If a nested class has the static attribute, then it can not access variables of the enclosing scope that are local to the stack or need a this: -

      -
      -
      
      +	
       	class Outer
       	{
       	    int m;
      @@ -966,7 +945,7 @@
       		}
       	    }
       	}
      -	

      + Non-static nested classes work by containing an extra hidden member (called the context pointer) @@ -981,9 +960,7 @@ A non-static nested class can only be instantiated when the necessary context pointer information is available: -

      -
      -
      
      +	
       	class Outer
       	{
       	    class Inner { }
      @@ -1001,15 +978,13 @@
       
       	    Nested n = new Nested;	// Ok
       	}
      -	

      + While a non-static nested class can access the stack variables of its enclosing function, that access becomes invalid once the enclosing function exits: -

      -
      -
      
      +	
       	class Base
       	{
       	    int foo() { return 1; }
      @@ -1034,15 +1009,13 @@
       	    Base b = func();
       	    return b.foo();		// Error, func().m is undefined
       	}
      -	

      + If this kind of functionality is needed, the way to make it work is to make copies of the needed variables within the nested class's constructor: -

      -
      -
      
      +	
       	class Base
       	{
       	    int foo() { return 1; }
      @@ -1069,43 +1042,39 @@
       	    Base b = func();
       	    return b.foo();		// Ok, using cached copy of func().m
       	}
      -	

      +

      Anonymous Nested Classes

      An anonymous nested class is both defined and instantiated with a NewAnonClassExpression: -

      -
      -
      
      +	
       	NewAnonClassExpression:
       	    new (ArgumentList)opt class (ArgumentList)opt SuperClassopt InterfaceClassesopt ClassBody
      -	

      + which is equivalent to: -

      -
      -
      
      +	
       	class Identifier : SuperClass InterfaceClasses
       		ClassBody
       
       	new (ArgumentList) Identifier (ArgumentList);
      -	

      + where Identifier is the name generated for the anonymous nested class. +

    Feedback and Comments

    - Add Add feedback and comments regarding this - page. + page.

    -
    -Copyright © 1999-2005 by Digital Mars, All Rights Reserved

    +

    -
    diff -uNr dmd-0.129/dmd/html/d/comparison.html dmd-0.130/dmd/html/d/comparison.html --- dmd-0.129/dmd/html/d/comparison.html 2005-06-08 12:43:56.000000000 +0200 +++ dmd-0.130/dmd/html/d/comparison.html 2005-08-26 11:54:10.000000000 +0200 @@ -12,9 +12,15 @@ - - + + + + + + + + + - + Digital Mars - The D Programming Language - Comparison + - - + www.digitalmars.com Home | Search | D +| Comments
    -Last update Wed Jun 08 2005 +Last update Fri Aug 26 2005
    + + + +
    +
    +
    + + + + + +
    +D
    +Language
    +Phobos
    +Comparisons +
    +
    + +D vs C/C++/C#/Java

    +Rationale for Builtins

    +Converting C to D

    +Converting C++ to D

    +The C Preprocessor vs D

    +D strings vs C++ std::string

    +D complex vs C++ std::complex

    +D Contract Programming vs C++

    +
    +
    +

    D vs Other Languages

    @@ -822,15 +860,15 @@ If I've made any errors in this table, please contact me so I can correct them: +

    Feedback and Comments

    - Add Add feedback and comments regarding this - page. + page.

    -
    -Copyright © 1999-2005 by Digital Mars, All Rights Reserved

    +

    -
    diff -uNr dmd-0.129/dmd/html/d/cppcomplex.html dmd-0.130/dmd/html/d/cppcomplex.html --- dmd-0.129/dmd/html/d/cppcomplex.html 2005-05-19 15:08:48.000000000 +0200 +++ dmd-0.130/dmd/html/d/cppcomplex.html 2005-08-26 11:54:10.000000000 +0200 @@ -12,9 +12,15 @@ - - + + + + + + + + + - + D Programming Language - D Complex Types vs C++ std::complex + - - + www.digitalmars.com Home | Search | D +| Comments
    -Last update Thu May 19 2005 +Last update Fri Aug 26 2005
    + + + +
    +
    +
    + + + + + +
    +D
    +Language
    +Phobos
    +Comparisons +
    +
    + +D vs C/C++/C#/Java

    +Rationale for Builtins

    +Converting C to D

    +Converting C++ to D

    +The C Preprocessor vs D

    +D strings vs C++ std::string

    +D complex vs C++ std::complex

    +D Contract Programming vs C++

    +
    +
    +

    D Complex Types and C++ std::complex

    @@ -48,74 +86,60 @@ In C++, the complex types are: -

    -
    -
    
    +	
     	complex<float>
     	complex<double>
     	complex<long double>
    -	

    + C++ has no distinct imaginary type. D has 3 complex types and 3 imaginary types: -

    -
    -
    
    +	
     	cfloat
     	cdouble
     	creal
     	ifloat
     	idouble
     	ireal
    -	

    + A C++ complex number can interact with an arithmetic literal, but since there is no imaginary type, imaginary numbers can only be created with the constructor syntax: -

    -
    -
    
    +	
     	complex<long double> a = 5;		// a = 5 + 0i
     	complex<long double> b(0,7);		// b = 0 + 7i
     	c = a + b + complex<long double>(0,7);	// c = 5 + 14i
    -	

    + In D, an imaginary numeric literal has the 'i' suffix. The corresponding code would be the more natural: -

    -
    -
    
    +	
     	creal a = 5;		// a = 5 + 0i
     	ireal b = 7i;		// b = 7i
     	c = a + b + 7i;		// c = 5 + 14i
    -	

    + For more involved expressions involving constants: -

    -
    -
    
    +	
     	c = (6 + 2i - 1 + 3i) / 3i;
    -	

    + In C++, this would be: -

    -
    -
    
    +	
     	c = (complex<double>(6,2) + complex<double>(-1,3)) / complex<double>(0,3);
    -	

    + or if an imaginary class were added to C++ it might be: -

    -
    -
    
    +	
     	c = (6 + imaginary<double>(2) - 1 + imaginary<double>(3))) / imaginary<double>(3);
    -	

    + In other words, an imaginary number nn can be represented with just nni rather than writing a constructor call @@ -128,39 +152,31 @@ on the 0 real part. For example, adding two imaginary numbers in D is one add: -

    -
    -
    
    +	
     	ireal a, b, c;
     	c = a + b;
    -	

    + In C++, it is two adds, as the real parts get added too: -

    -
    -
    
    +	
     	c.re = a.re + b.re;
     	c.im = a.im + b.im;
    -	

    + Multiply is worse, as 4 multiplies and two adds are done instead of one multiply: -

    -
    -
    
    +	
     	c.re = a.re * b.re - a.im * b.im;
     	c.im = a.im * b.re + a.re * b.im;
    -	

    + Divide is the worst - D has one divide, whereas C++ implements complex division with typically one comparison, 3 divides, 3 multiplies and 3 additions: -

    -
    -
    
    +	
     	if (fabs(b.re) < fabs(b.im))
     	{
     	    r = b.re / b.im;
    @@ -175,28 +191,24 @@
     	    c.re = (a.re + r * a.im) / den;
     	    c.im = (a.im - r * a.re) / den;
     	}
    -	

    + To avoid these efficiency concerns in C++, one could simulate an imaginary number using a double. For example, given the D: -

    -
    -
    
    +	
     	cdouble c;
     	idouble im;
     	c *= im;
    -	

    + it could be written in C++ as: -

    -
    -
    
    +	
     	complex<double> c;
     	double im;
     	c = complex<double>(-c.imag() * im, c.real() * im);
    -	

    + but then the advantages of complex being a library type integrated in with the arithmetic operators have been lost. @@ -256,15 +268,15 @@ 7 in The State of the Art in Numerical Analysis (1987) ed. by M. Powell and A. Iserles for Oxford U.P. +

    Feedback and Comments

    - Add Add feedback and comments regarding this - page. + page.

    -
    -Copyright © 1999-2005 by Digital Mars, All Rights Reserved

    +

    -
    diff -uNr dmd-0.129/dmd/html/d/cppdbc.html dmd-0.130/dmd/html/d/cppdbc.html --- dmd-0.129/dmd/html/d/cppdbc.html 2005-05-19 15:08:48.000000000 +0200 +++ dmd-0.130/dmd/html/d/cppdbc.html 2005-08-26 11:54:10.000000000 +0200 @@ -12,9 +12,15 @@ - - + + + + + + + + + - + D Programming Language - D's Contract Programming vs C++'s + - - + www.digitalmars.com Home | Search | D +| Comments
    -Last update Thu May 19 2005 +Last update Fri Aug 26 2005
    + + + +
    +
    +
    + + + + + +
    +D
    +Language
    +Phobos
    +Comparisons +
    +
    + +D vs C/C++/C#/Java

    +Rationale for Builtins

    +Converting C to D

    +Converting C++ to D

    +The C Preprocessor vs D

    +D strings vs C++ std::string

    +D complex vs C++ std::complex

    +D Contract Programming vs C++

    +
    +
    +

    D's Contract Programming vs C++'s

    @@ -119,9 +157,7 @@ Consider a class invariant in D: -

    -
    -
    
    +	
     	class A
     	{
     	    invariant() { ...contracts... }
    @@ -137,14 +173,12 @@
     	    invariant() { ...contracts... }
     	    ...
     	}
    -	

    + To accomplish the equivalent in C++ (thanks to Bob Bell for providing this): -

    -
    -
    
    +	
     	template
     	inline void check_invariant(T& iX)
     	{
    @@ -195,16 +229,14 @@
     	    ...
     	    check_invariant(*this);
     	}
    -	

    + There's an additional complication with A::foo(). Upon every normal exit from the function, the invariant() should be called. This means that code that looks like: -

    -
    -
    
    +	
     	int A::foo()
     	{
     	    ...
    @@ -212,13 +244,11 @@
     		return bar();
     	    return 3;
     	}
    -	

    + would need to be written as: -

    -
    -
    
    +	
     	int A::foo()
     	{
     	    int result;
    @@ -233,14 +263,12 @@
     	    check_invariant(*this);
     	    return 3;
     	}
    -	

    + Or recode the function so it has a single exit point. One possibility to mitigate this is to use RAII techniques: -

    -
    -
    
    +	
     	int A::foo()
     	{
     	#if DBC
    @@ -255,7 +283,7 @@
     		return bar();
     	    return 3;
     	}
    -	

    + The #if DBC is still there because some compilers may not optimize the whole thing away if check_invariants compiles to nothing. @@ -264,9 +292,7 @@ Consider the following in D: -

    -
    -
    
    +	
     	void foo()
     	    in { ...preconditions... }
     	    out { ...postconditions... }
    @@ -274,13 +300,11 @@
     	    {
     		...implementation...
     	    }
    -	

    + This is nicely handled in C++ with the nested Sentry struct: -

    -
    -
    
    +	
     	void foo()
     	{
     	    struct Sentry
    @@ -289,7 +313,7 @@
     	    } sentry;
     	    ...implementation...
     	}
    -	

    + If the preconditions and postconditions consist of nothing more than assert macros, the whole doesn't need to @@ -301,9 +325,7 @@ to walk the array and verify that it really is sorted. Now the shebang needs to be wrapped in #ifdef: -

    -
    -
    
    +	
     	void foo()
     	{
     	#ifdef DBC
    @@ -314,7 +336,7 @@
     	#endif
     	    ...implementation...
     	}
    -	

    + (One can make use of the C++ rule that templates are only instantiated when used can be used to avoid the #ifdef, by @@ -325,9 +347,7 @@ Let's add a return value to foo() that needs to be checked in the postconditions. In D: -

    -
    -
    
    +	
     	int foo()
     	    in { ...preconditions... }
     	    out (result) { ...postconditions... }
    @@ -338,13 +358,11 @@
     		    return bar();
     		return 3;
     	    }
    -	

    + In C++: -

    -
    -
    
    +	
     	int foo()
     	{
     	#ifdef DBC
    @@ -367,13 +385,11 @@
     	#endif
     	    return 3;
     	}
    -	

    + Now add a couple parameters to foo(). In D: -

    -
    -
    
    +	
     	int foo(int a, int b)
     	    in { ...preconditions... }
     	    out (result) { ...postconditions... }
    @@ -384,13 +400,11 @@
     		    return bar();
     		return 3;
     	    }
    -	

    + In C++: -

    -
    -
    
    +	
     	int foo(int a, int b)
     	{
     	#ifdef DBC
    @@ -418,16 +432,14 @@
     	#endif
     		return 3;
     	}
    -	

    +

    Preconditions and Postconditions for Member Functions

    Consider the use of preconditions and postconditions for a polymorphic function in D: -

    -
    -
    
    +	
     	class A
     	{
     	    void foo()
    @@ -449,7 +461,7 @@
     		    ...implementation...
     		}
     	}
    -	

    + The semantics for a call to B.foo() are: @@ -460,9 +472,7 @@ Let's get this to work in C++: -

    -
    -
    
    +	
     	class A
     	{
     	protected:
    @@ -513,7 +523,7 @@
     		foo_postconditions();
     	    }
     	};
    -	

    + Something interesting has happened here. The preconditions can no longer be done using assert, since the results need @@ -552,15 +562,15 @@ Bjarne Stroustrup, Addison-Wesley

    +

    Feedback and Comments

    - Add Add feedback and comments regarding this - page. + page.

    -
    -Copyright © 1999-2005 by Digital Mars, All Rights Reserved

    +

    -
    diff -uNr dmd-0.129/dmd/html/d/cppstrings.html dmd-0.130/dmd/html/d/cppstrings.html --- dmd-0.129/dmd/html/d/cppstrings.html 2005-06-14 15:15:52.000000000 +0200 +++ dmd-0.130/dmd/html/d/cppstrings.html 2005-08-26 11:54:10.000000000 +0200 @@ -12,9 +12,15 @@ - - + + + + + + + + + - + D Programming Language - D Strings vs C++ Strings + - - + www.digitalmars.com Home | Search | D +| Comments
    -Last update Tue Jun 14 2005 +Last update Fri Aug 26 2005
    + + + +
    +
    +
    + + + + + +
    +D
    +Language
    +Phobos
    +Comparisons +
    +
    + +D vs C/C++/C#/Java

    +Rationale for Builtins

    +Converting C to D

    +Converting C++ to D

    +The C Preprocessor vs D

    +D strings vs C++ std::string

    +D complex vs C++ std::complex

    +D Contract Programming vs C++

    +
    +
    +

    D Strings vs C++ Strings

    @@ -75,111 +113,91 @@ is overloadable. So the C++ string class cannot consistently handle arbitrary expressions containing strings. Consider: -

    -
    -
    
    +
             const char abc[5] = "world";
             string str = "hello" + abc;
     
    -

    + That isn't going to work. But it does work when the core language knows about strings: -

    -
    -
    
    +
     	const char[5] abc = "world";
     	char[] str = "hello" ~ abc;
     
    -

    +

    Consistency With C String Syntax

    There are three ways to find the length of a string in C++: -

    -
    -
    
    +
     	const char abc[] = "world";	:	sizeof(abc)/sizeof(abc[0])-1
     					:	strlen(abc)
     	string str			:	str.length()
     
    -

    + That kind of inconsistency makes it hard to write generic templates. Consider D: -

    -
    -
    
    +
     	char[5] abc = "world";	:	abc.length
     	char[] str		:	str.length
     
    -

    +

    Checking For Empty Strings

    C++ strings use a function to determine if a string is empty: -

    -
    -
    
    +
     	string str;
     	if (str.empty())
     		// string is empty
    -

    + In D, an empty string has zero length: -

    -
    -
    
    +
     	char[] str;
     	if (!str.length)
     		// string is empty
    -

    +

    Resizing Existing String

    C++ handles this with the resize() member function: -

    -
    -
    
    +
     	string str;
     	str.resize(newsize);
    -

    + D takes advantage of knowing that str is a string, and so resizing it is just changing the length property: -

    -
    -
    
    +
     	char[] str;
     	str.length = newsize;
    -

    +

    Slicing a String

    C++ slices an existing string using a special constructor: -

    -
    -
    
    +
     	string s1 = "hello world";
     	string s2(s1, 6, 5);		// s2 is "world"
    -

    + D has the array slice syntax, not possible with C++: -

    -
    -
    
    +
     	char[] s1 = "hello world";
     	char[] s2 = s1[6 .. 11];	// s2 is "world"
    -

    + Slicing, of course, works with any array in D, not just strings. @@ -187,46 +205,38 @@ C++ copies strings with the replace function: -

    -
    -
    
    +
     	string s1 = "hello world";
     	string s2 = "goodbye      ";
     	s2.replace(8, 5, s1, 6, 5);	// s2 is "goodbye world"
    -

    + D uses the slice syntax as an lvalue: -

    -
    -
    
    +
     	char[] s1 = "hello world";
     	char[] s2 = "goodbye      ";
     	s2[8..13] = s1[6..11];		// s2 is "goodbye world"
    -

    +

    Conversions to C Strings

    This is needed for compatibility with C API's. In C++, this uses the c_str() member function: -

    -
    -
    
    +
     	void foo(const char *);
     	string s1;
     	foo(s1.c_str());
    -

    + In D, strings can be implicitly converted to char*: -

    -
    -
    
    +
     	void foo(char *);
     	char[] s1;
     	foo(s1);
    -

    + Note: some will argue that it is a mistake in D to have an implicit conversion from char[] to char*. @@ -243,16 +253,14 @@ by adding more to the library. In D, they take the obvious syntactical forms: -

    -
    -
    
    +
     	switch (str)
     	{
     	    case "hello":
     	    case "world":
     		...
     	}
    -

    + where str can be any of literal "string"s, fixed string arrays like char[10], or dynamic strings like char[]. A quality implementation @@ -263,21 +271,17 @@ In C++, this is done with the replace() member function: -

    -
    -
    
    +
     	string str = "hello";
     	str.replace(1,2,2,'?');		// str is "h??lo"
    -

    + In D, use the array slicing syntax in the natural manner: -

    -
    -
    
    +
     	char[] str = "hello";
     	str[1..2] = '?';		// str is "h??lo"
    -

    +

    Value vs Reference

    @@ -324,9 +328,7 @@ Let's take a look at a small utility, wordcount, that counts up the frequency of each word in a text file. In D, it looks like this: -

    -
    -
    
    +	
     	import file;
     
     	int main (char[][] args)
    @@ -397,7 +399,7 @@
     	    }
     	    return 0;
     	}
    -	

    + Two people have written C++ implementations using the C++ standard template library, @@ -525,9 +527,7 @@


    wccpp2 by Allan Odgaard

    -

    -
    -
    
    +	
     	#include <algorithm>
     	#include <cstdio>
     	#include <fstream>
    @@ -580,17 +580,17 @@
     
     	    return 0;
     	}
    -	

    + +

    Feedback and Comments

    - Add Add feedback and comments regarding this - page. + page.

    -
    -Copyright © 1999-2005 by Digital Mars, All Rights Reserved

    +

    -
    diff -uNr dmd-0.129/dmd/html/d/cpptod.html dmd-0.130/dmd/html/d/cpptod.html --- dmd-0.129/dmd/html/d/cpptod.html 2005-06-14 15:15:52.000000000 +0200 +++ dmd-0.130/dmd/html/d/cpptod.html 2005-08-26 11:54:10.000000000 +0200 @@ -13,9 +13,15 @@ - - + + + + + + + + + - + Digital Mars - Programming in D for C++ Programmers + - - + www.digitalmars.com Home | Search | D +| Comments
    -Last update Tue Jun 14 2005 +Last update Fri Aug 26 2005 +
    + + + +
    +
    +
    + + + + + +
    +D
    +Language
    +Phobos
    +Comparisons +

    + +D vs C/C++/C#/Java

    +Rationale for Builtins

    +Converting C to D

    +Converting C++ to D

    +The C Preprocessor vs D

    +D strings vs C++ std::string

    +D complex vs C++ std::complex

    +D Contract Programming vs C++

    +
    +
    +

    Programming in D for C++ Programmers

    @@ -81,25 +119,21 @@ Constructors have the same name as the class: -

    -
    -
    
    +	
     	class Foo
     	{
     		Foo(int x); 
    -	};

    + };

    The D Way

    Constructors are defined with the this keyword: -

    -
    -
    
    +	
     	class Foo
     	{
     		this(int x) { } 
    -	}

    + } which reflects how they are used in D. @@ -110,9 +144,7 @@ Base constructors are called using the base initializer syntax. -

    -
    -
    
    +	
     	class A { A() {... } };
     	class B : A
     	{
    @@ -120,15 +152,13 @@
     		: A()		// call base constructor 
     	     {	...
     	     }
    -	};

    + };

    The D Way

    The base class constructor is called with the super syntax: -

    -
    -
    
    +	
     	class A { this() { ... } }
     	class B : A
     	{
    @@ -137,14 +167,12 @@
     		super();	// call base constructor 
     		...
     	     }
    -	}

    + } It's superior to C++ in that the base constructor call can be flexibly placed anywhere in the derived constructor. D can also have one constructor call another one: -

    -
    -
    
    +	
     	class A
     	{	int a;
     		int b;
    @@ -154,14 +182,12 @@
     		    this();
     		    a = x;
     		}
    -	}

    + } Members can also be initialized to constants before the constructor is ever called, so the above example is equivalently written as: -

    -
    -
    
    +	
     	class A
     	{	int a = 7;
     		int b;
    @@ -171,7 +197,7 @@
     		    this();
     		    a = x;
     		}
    -	}

    + }


    Comparing structs

    @@ -180,20 +206,16 @@ While C++ defines struct assignment in a simple, convenient manner: -

    -
    -
    
    +	
     	struct A x, y; 
     	...
     	x = y;
    -	

    + it does not for struct comparisons. Hence, to compare two struct instances for equality: -

    -
    -
    
    +	
     	#include <string.h>
     
     	struct A x, y;
    @@ -205,7 +227,7 @@
     	...
     	if (x == y)
     	    ...
    -	

    + Note that the operator overload must be done for every struct needing to be compared, and the implementation of that overloaded @@ -236,14 +258,12 @@ D does it the obvious, straightforward way: -

    -
    -
    
    +	
     	A x, y;
     	...
     	if (x == y) 
     	    ...
    -	

    +


    Creating a new typedef'd type

    @@ -254,9 +274,7 @@ a new type. The compiler doesn't distinguish between a typedef and its underlying type. -

    -
    -
    
    +	
     	#define HANDLE_INIT	((Handle)(-1))
     	typedef void *Handle;
     	void foo(void *);
    @@ -265,14 +283,12 @@
     	Handle h = HANDLE_INIT;
     	foo(h);			// coding bug not caught 
     	bar(h);			// ok
    -	

    + The C++ solution is to create a dummy struct whose sole purpose is to get type checking and overloading on the new type. -

    -
    -
    
    +	
     	#define HANDLE_INIT	((void *)(-1)) 
     	struct Handle
     	{   void *ptr;
    @@ -292,15 +308,13 @@
     	h = func();
     	if (h != HANDLE_INIT)
     	    ...
    -	

    +

    The D Way

    No need for idiomatic constructions like the above. Just write: -

    -
    -
    
    +	
     	typedef void *Handle = cast(void *)-1; 
     	void bar(Handle);
     
    @@ -309,7 +323,7 @@
     	h = func();
     	if (h != Handle.init)
     	    ...
    -	

    + Note how a default initializer can be supplied for the typedef as a value of the underlying type. @@ -323,9 +337,7 @@ but need to access each other's private members. This is done using friend declarations: -

    -
    -
    
    +	
     	class A
     	{
     	    private:
    @@ -351,7 +363,7 @@
     	int B::bar(A *j) { return j->a; } 
     
     	int abc(A *p) { return p->a; }
    -	

    +

    The D Way

    @@ -360,9 +372,7 @@ in the same module, so implicitly granting friend access to other module members solves the problem neatly: -

    -
    -
    
    +	
     	module X;
     
     	class A
    @@ -384,7 +394,7 @@
     	}
     
     	int abc(A p) { return p.a; }
    -	

    + The private attribute prevents other modules from accessing the members. @@ -398,9 +408,7 @@ it's convenient to overload the comparison operators so it can be compared against integers: -

    -
    -
    
    +	
     	struct A
     	{
     		int operator <  (int i);
    @@ -413,7 +421,7 @@
     	int operator <= (int i, A &a) { return a >= i; }
     	int operator >  (int i, A &a) { return a <  i; }
     	int operator >= (int i, A &a) { return a <= i; } 
    -	

    + A total of 8 functions are necessary. @@ -422,14 +430,12 @@ D recognizes that the comparison operators are all fundamentally related to each other. So only one function is necessary: -

    -
    -
    
    +	
     	struct A
     	{
     		int opCmp(int i); 
     	}
    -	

    + The compiler automatically interprets all the <, <=, > and >= @@ -451,24 +457,20 @@ A using-declaration in C++ is used to bring a name from a namespace scope into the current scope: -

    -
    -
    
    +	
     	namespace Foo 
     	{
     	    int x;
     	}
     	using Foo::x;
    -	

    +

    The D Way

    D uses modules instead of namespaces and #include files, and alias declarations take the place of using declarations: -

    -
    -
    
    +	
     	---- Module Foo.d ------
     	module Foo;
     	int x;
    @@ -476,7 +478,7 @@
     	---- Another module ---- 
     	import Foo;
     	alias Foo.x x;
    -	

    + Alias is a much more flexible than the single purpose using declaration. Alias can be used to rename symbols, refer to @@ -492,9 +494,7 @@ leaving a scope, RAII is implemented by putting the resource release code into the destructor: -

    -
    -
    
    +	
     	class File
     	{   Handle *h;
     
    @@ -503,7 +503,7 @@
     		h->release(); 
     	    }
     	};
    -	

    +

    The D Way

    @@ -517,9 +517,7 @@ The few RAII issues left are handled by auto classes. Auto classes get their destructors run when they go out of scope. -

    -
    -
    
    +	
     	auto class File
     	{   Handle h;
     
    @@ -537,7 +535,7 @@
     	    } // f.~this() gets run at closing brace, even if 
     	      // scope was exited via a thrown exception
     	}
    -	

    +


    Properties

    @@ -548,9 +546,7 @@ along with object-oriented get and set functions for it: -

    -
    -
    
    +	
     	class Abc
     	{
     	  public:
    @@ -564,7 +560,7 @@
     	Abc a;
     	a.setProperty(3);
     	int x = a.getProperty();
    -	

    + All this is quite a bit of typing, and it tends to make code unreadable by filling @@ -575,9 +571,7 @@ Properties can be get and set using the normal field syntax, yet the get and set will invoke methods instead. -

    -
    -
    
    +	
     	class Abc
     	{
     	    // set 
    @@ -589,17 +583,15 @@
     	  private:
     	    int myprop;
     	}
    -	

    + which is used as: -

    -
    -
    
    +	
     	Abc a;
     	a.property = 3;		// equivalent to a.property(3)
     	int x = a.property;	// equivalent to int x = a.property() 
    -	

    + Thus, in D a property can be treated like it was a simple field name. A property can start out actually being a simple field name, @@ -621,9 +613,7 @@ them, relying on specialization to end it. A template to compute a factorial would be: -

    -
    -
    
    +	
     	template<int n> class factorial
     	{
     	    public:
    @@ -639,7 +629,7 @@
     	void test()
     	{
     	    printf("%d\n", factorial<4>::result); // prints 24
    -	}

    + }

    The D Way

    @@ -647,9 +637,7 @@ advantage of promotion of single template members to the enclosing name space: -

    -
    -
    
    +	
     	template factorial(int n)
     	{
     	    enum { factorial = n* .factorial!(n-1) }
    @@ -663,7 +651,7 @@
     	void test()
     	{
     	    printf("%d\n", factorial!(4));	// prints 24 
    -	}

    + }


    @@ -697,9 +685,7 @@ A preprocessor macro is also needed to make up for the lack of template typedefs. -

    -
    -
    
    +	
     	#include <limits.h>
     
     	template< int nbits > struct Integer
    @@ -750,7 +736,7 @@
     	    printf("%d %d %d %d\n",
     		sizeof(i), sizeof(j), sizeof(k), sizeof(l)); 
     	    return 0 ;
    -	}

    + }

    The D Way

    @@ -762,9 +748,7 @@ It compiles quickly, and gives a sensible compile time message if it fails. -

    -
    -
    
    +	
     	template Integer(int nbits)
     	{
     	    static if (nbits <= 8)
    @@ -788,7 +772,7 @@
     	    printf("%d %d %d %d\n",
     		i.sizeof, j.sizeof, k.sizeof, l.sizeof); 
     	    return 0;
    -	}

    + }


    @@ -805,9 +789,7 @@ pg. 353 which determines if the template's argument type is a function: -

    -
    -
    
    +	
     	template<typename T> class IsFunctionT
     	{
     	    private:
    @@ -825,7 +807,7 @@
     
     	    assert(IsFunctionT<fp>::Yes == 1);
     	}
    -	

    + This template relies on the SFINAE @@ -837,9 +819,7 @@ SFINAE can be done in D without resorting to template argument pattern matching: -

    -
    -
    
    +	
     	template IsFunctionT(T)
     	{
     	    static if ( is(T[]) )
    @@ -854,7 +834,7 @@
     
     	    assert(IsFunctionT!(fp) == 1);
     	}
    -	

    + The task of discovering if a type is a function doesn't need a template at all, nor does it need the subterfuge of attempting to @@ -862,27 +842,25 @@ The is expression can test it directly: -

    -
    -
    
    +	
     	void test()
     	{
     	    typedef int fp(int);
     
     	    assert( is(fp == function) );
     	}
    -	

    + +

    Feedback and Comments

    - Add Add feedback and comments regarding this - page. + page.

    -
    -Copyright © 1999-2005 by Digital Mars, All Rights Reserved

    +

    -
    diff -uNr dmd-0.129/dmd/html/d/ctod.html dmd-0.130/dmd/html/d/ctod.html --- dmd-0.129/dmd/html/d/ctod.html 2005-05-22 02:32:44.000000000 +0200 +++ dmd-0.130/dmd/html/d/ctod.html 2005-08-26 11:54:10.000000000 +0200 @@ -12,9 +12,15 @@ - - + + + + + + + + + - + Digital Mars - Programming in D for C Programmers + - - + www.digitalmars.com Home | Search | D +| Comments
    -Last update Sun May 22 2005 +Last update Fri Aug 26 2005 +
    + + + +
    +
    +
    + + + + + +
    +D
    +Language
    +Phobos
    +Comparisons +

    + +D vs C/C++/C#/Java

    +Rationale for Builtins

    +Converting C to D

    +Converting C++ to D

    +The C Preprocessor vs D

    +D strings vs C++ std::string

    +D complex vs C++ std::complex

    +D Contract Programming vs C++

    +
    +
    +

    Programming in D for C Programmers

    @@ -109,23 +147,19 @@

    The C Way

    -

    -
    -
    	sizeof(int)
    +
    	sizeof(int)
     	sizeof(char *)
     	sizeof(double)
    -	sizeof(struct Foo)

    + sizeof(struct Foo)

    The D Way

    Use the size property:

    -

    -
    -
            int.size
    +
            int.size
             (char *).size
             double.size
    -        Foo.size

    + Foo.size


    @@ -133,26 +167,22 @@

    The C Way

    -

    -
    -
    	#include <limits.h>
    +
    	#include <limits.h>
     	#include <math.h>
     
     	CHAR_MAX
     	CHAR_MIN
     	ULONG_MAX
     	DBL_MIN
    -

    +

    The D Way

    -

    -
    -
            char.max
    +
            char.max
             char.min
             ulong.max
             double.min
    -

    +


    @@ -160,9 +190,7 @@

    C to D types

    -

    -
    -
            bool               =>        bit 
    +
            bool               =>        bit 
             char               =>        char 
             signed char        =>        byte 
             unsigned char      =>        ubyte 
    @@ -181,7 +209,7 @@
     	_Imaginary long double =>    imaginary
     	_Complex long double   =>    complex
     
    -

    +

    Although char is an unsigned 8 bit type, and wchar is an unsigned 16 bit type, they have their own separate types @@ -195,9 +223,7 @@

    The C Way

    -

    -
    -
           #include <fp.h> 
    +
           #include <fp.h> 
     
            NAN 
            INFINITY 
    @@ -211,13 +237,11 @@
            DBL_MAX_EXP 
            DBL_MIN_10_EXP 
            DBL_MIN_EXP 
    -

    +

    The D Way

    -

    -
    -
           double.nan 
    +
           double.nan 
            double.infinity 
            double.dig 
            double.epsilon 
    @@ -226,34 +250,30 @@
            double.max_exp 
            double.min_10_exp 
            double.min_exp 
    -

    +


    Remainder after division of floating point numbers

    The C Way

    -

    -
    -
    
    +
            #include <math.h> 
     
            float f = fmodf(x,y); 
            double d = fmod(x,y); 
            long double e = fmodl(x,y); 
    -

    +

    The D Way

    D supports the remainder ('%') operator on floating point operands: -

    -
    -
    
    +
            float f = x % y; 
            double d = x % y; 
            extended e = x % y; 
    -

    +


    @@ -265,26 +285,22 @@ is NAN, and few C compilers check for it (the Digital Mars C compiler is an exception, DM's compilers do check for NAN operands). -

    -
    -
    
    +
            #include <math.h> 
     
            if (isnan(x) || isnan(y)) 
     	   result = FALSE; 
            else 
     	   result = (x < y); 
    -

    +

    The D Way

    D offers a full complement of comparisons and operators that work with NAN arguments. -

    -
    -
           result = (x < y);        // false if x or y is nan 
    -

    +

           result = (x < y);        // false if x or y is nan 
    +

    @@ -296,23 +312,19 @@ and __LINE__ from which an assert macro can be built. In fact, there appears to be practically no other use for __FILE__ and __LINE__. -

    -
    -
    
    +
            #include <assert.h> 
     
            assert(e == 0); 
    -

    +

    The D Way

    D simply builds assert into the language: -

    -
    -
    
    +
            assert(e == 0); 
    -

    + [NOTE: trace functions?] @@ -322,23 +334,19 @@

    The C Way

    -

    -
    -
    
    +
            #define ARRAY_LENGTH        17 
            int array[ARRAY_LENGTH]; 
            for (i = 0; i < ARRAY_LENGTH; i++) 
     	   array[i] = value; 
    -

    +

    The D Way

    -

    -
    -
    
    +
            int array[17]; 
            array[] = value; 
    -

    +


    @@ -349,46 +357,38 @@ The array length is defined separately, or a clumsy sizeof() expression is used to get the length. -

    -
    -
    
    +
            #define ARRAY_LENGTH        17 
            int array[ARRAY_LENGTH]; 
            for (i = 0; i < ARRAY_LENGTH; i++) 
     	   func(array[i]); 
    -

    + or: -

    -
    -
    
    +
            int array[17]; 
            for (i = 0; i < sizeof(array) / sizeof(array[0]); i++) 
     	   func(array[i]); 
    -

    +

    The D Way

    The length of an array is accessible the property "length". -

    -
    -
    
    +
            int array[17]; 
            for (i = 0; i < array.length; i++) 
     	   func(array[i]); 
    -

    + or even better: -

    -
    -
    
    +
            int array[17]; 
            foreach (int value; array)
     	   func(value); 
    -

    +


    @@ -401,9 +401,7 @@ variable for the length, and then explicitly manage the size of the array: -

    -
    -
    
    +
            #include <stdlib.h> 
     
            int array_length; 
    @@ -416,21 +414,19 @@
     	   error("out of memory"); 
            array = newarray; 
            array[array_length++] = x; 
    -

    +

    The D Way

    D supports dynamic arrays, which can be easily resized. D supports all the requisite memory management. -

    -
    -
    
    +
            int[] array; 
     
            array.length = array.length + 1;
            array[array.length - 1] = x; 
    -

    +


    @@ -442,9 +438,7 @@ when can storage be free'd, dealing with null pointers, finding the length of the strings, and memory allocation: -

    -
    -
     
    +
     
            #include <string.h> 
     
            char *s1; 
    @@ -474,23 +468,21 @@
     	   error("out of memory"); 
            s = news; 
            memcpy(s + lens, hello, sizeof(hello)); 
    -

    +

    The D Way

    D overloads the operators ~ and ~= for char and wchar arrays to mean concatenate and append, respectively: -

    -
    -
    
    +
            char[] s1; 
            char[] s2; 
            char[] s; 
     
            s = s1 ~ s2; 
            s ~= "hello"; 
    -

    +


    @@ -500,25 +492,21 @@ printf() is the general purpose formatted print routine: -

    -
    -
    
    +
            #include <stdio.h> 
     
            printf("Calling all cars %d times!\n", ntimes); 
    -

    +

    The D Way

    What can we say? printf() rules: -

    -
    -
    
    +
            import stdio; 
     
            printf("Calling all cars %d times!\n", ntimes); 
    -

    +


    @@ -530,9 +518,7 @@ not yet encountered in the source file, it is necessary to insert a function declaration lexically preceding the call. -

    -
    -
    
    +
            void forwardfunc(); 
     
            void myfunc() 
    @@ -544,7 +530,7 @@
            {   
     	   ... 
            } 
    -

    +

    The D Way

    @@ -554,9 +540,7 @@ referenced function declarations twice. Functions can be defined in any order. -

    -
    -
    
    +
             void myfunc() 
             {   
     	   forwardfunc(); 
    @@ -566,7 +550,7 @@
             {   
     	   ... 
             } 
    -

    +


    @@ -574,11 +558,9 @@

    The C Way

    -

    -
    -
    
    +
            void function(void); 
    -

    +

    The D Way

    @@ -586,14 +568,12 @@ say a function takes no arguments, just don't declare it has having arguments. -

    -
    -
    
    +
            void function() 
            {   
     	   ... 
            } 
    -

    +


    @@ -604,9 +584,7 @@ Break's and continue's only apply to the innermost nested loop or switch, so a multilevel break must use a goto: -

    -
    -
    
    +
                    for (i = 0; i < 10; i++) 
                    { 
                        for (j = 0; j < 10; j++) 
    @@ -621,7 +599,7 @@
                    } 
                Louter: 
                    ; 
    -

    +

    The D Way

    @@ -629,9 +607,7 @@ is the label for an enclosing loop or switch, and the break applies to that loop. -

    -
    -
    
    +
                  Louter: 
                    for (i = 0; i < 10; i++) 
                    { 
    @@ -644,7 +620,7 @@
                        } 
                    } 
                    // break Louter goes here 
    -

    +


    @@ -670,22 +646,18 @@ It's annoying to have to put the struct keyword every time a type is specified, so a common idiom is to use: -

    -
    -
    
    +
                    typedef struct ABC { ... } ABC; 
    -

    +

    The D Way

    Struct tag names are not in a separate name space, they are in the same name space as ordinary names. Hence: -

    -
    -
    
    +
                    struct ABC { ... }; 
    -

    +


    @@ -697,9 +669,7 @@ values and take action based on which one it is. A typical use for this might be command line argument processing. -

    -
    -
    
    +
                    #include <string.h> 
                    void dostring(char *s) 
                    { 
    @@ -720,7 +690,7 @@
                            default:        ... 
                        } 
                    } 
    -

    + The problem with this is trying to maintain 3 parallel data structures, the enum, the table, and the switch cases. If there @@ -740,9 +710,7 @@ strings as well as numbers. Then, the way to code the string lookup becomes straightforward: -

    -
    -
    
    +
                    void dostring(char[] s) 
                    { 
                        switch (s) 
    @@ -753,7 +721,7 @@
                            default:        ... 
                        } 
                    } 
    -

    + Adding new cases becomes easy. The compiler can be relied on to generate a fast lookup scheme for it, eliminating the bugs @@ -769,16 +737,14 @@ program, and woe results if any modules or libraries didn't get recompiled. To address this, #pragma's are used: -

    -
    -
    
    +
                #pragma pack(1) 
                struct ABC 
                { 
                    ... 
                }; 
                #pragma pack() 
    -

    + But #pragmas are nonportable both in theory and in practice from compiler to compiler. @@ -788,9 +754,7 @@ Clearly, since much of the point to setting alignment is for portability of data, a portable means of expressing it is necessary. -

    -
    -
    
    +
                struct ABC 
                { 
                    int z;               // z is aligned to the default 
    @@ -804,7 +768,7 @@
     
                    int y;               // y is word aligned 
                } 
    -

    +


    @@ -817,9 +781,7 @@ C doesn't allow anonymous structs or unions, which means that dummy tag names and dummy members are necessary: -

    -
    -
    
    +
                struct Foo 
                {   int i; 
                    union Bar 
    @@ -839,7 +801,7 @@
                f.x; 
                f.y; 
                f.p; 
    -

    + Not only is it clumsy, but using macros means a symbolic debugger won't understand what is being done, and the macros have global scope instead of struct scope. @@ -849,9 +811,7 @@ Anonymous structs and unions are used to control the layout in a more natural manner: -

    -
    -
    
    +
                struct Foo 
                {   int i; 
                    union 
    @@ -867,7 +827,7 @@
                f.x; 
                f.y; 
                f.p; 
    -

    +


    @@ -877,31 +837,25 @@ Is to do it in one statement ending with a semicolon: -

    -
    -
    
    +
                struct Foo { int x; int y; } foo; 
    -

    + Or to separate the two: -

    -
    -
    
    +
                struct Foo { int x; int y; };   // note terminating ; 
                struct Foo foo; 
    -

    +

    The D Way

    Struct definitions and declarations can't be done in the same statement: -

    -
    -
    
    +
                struct Foo { int x; int y; }    // note there is no terminating ; 
                Foo foo; 
    -

    + which means that the terminating ; can be dispensed with, eliminating the confusing difference between struct {} and function & block {} in how semicolons @@ -915,26 +869,22 @@ Naturally, another macro is used: -

    -
    -
    
    +
                #include <stddef> 
                struct Foo { int x; int y; }; 
     
                off = offsetof(Foo, y); 
    -

    +

    The D Way

    An offset is just another property: -

    -
    -
    
    +
                struct Foo { int x; int y; } 
     
                off = Foo.y.offset; 
    -

    +


    @@ -944,12 +894,10 @@ Unions are initialized using the "first member" rule: -

    -
    -
    
    +
                union U { int a; long b; }; 
                union U x = { 5 };                // initialize member 'a' to 5 
    -

    + Adding union members or rearranging them can have disastrous consequences for any initializers. @@ -958,12 +906,10 @@ In D, which member is being initialized is mentioned explicitly: -

    -
    -
    
    +
                union U { int a; long b; } 
                U x = { a:5 } 
    -

    + avoiding the confusion and maintenance problems. @@ -975,12 +921,10 @@ Members are initialized by their position within the {}'s: -

    -
    -
    
    +
                struct S { int a; int b; }; 
                struct S x = { 5, 3 }; 
    -

    + This isn't much of a problem with small structs, but when there are numerous members, it becomes tedious to get the initializers @@ -992,12 +936,10 @@ Member initialization can be done explicitly: -

    -
    -
    
    +
                struct S { int a; int b; } 
                S x = { b:3, a:5 } 
    -

    + The meaning is clear, and there no longer is a positional dependence. @@ -1008,46 +950,36 @@

    The C Way

    C initializes array by positional dependence: -

    -
    -
    
    +
                int a[3] = { 3,2,2 }; 
    -

    + Nested arrays may or may not have the { }: -

    -
    -
    
    +
                int b[3][2] = { 2,3, {6,5}, 3,4 }; 
    -

    +

    The D Way

    D does it by positional dependence too, but an index can be used as well: The following all produce the same result: -

    -
    -
    
    +
         int[3] a = [ 3, 2, 0 ]; 
         int[3] a = [ 3, 2 ];            // unsupplied initializers are 0, just like in C 
         int[3] a = [ 2:0, 0:3, 1:2 ]; 
         int[3] a = [ 2:0, 0:3, 2 ];     // if not supplied, the index is the
                                         // previous one plus one. 
    -

    + This can be handy if the array will be indexed by an enum, and the order of enums may be changed or added to: -

    -
    -
    
    +
         enum color { black, red, green }
         int[3] c = [ black:3, green:2, red:5 ]; 
    -

    + Nested array initializations must be explicit: -

    -
    -
    
    +
         int[2][3] b = [ [2,3], [6,5], [3,4] ]; 
     
         int[2][3] b = [[2,6,3],[3,5,4]];            // error 
    -

    +


    @@ -1056,40 +988,30 @@

    The C Way

    C has problems with the DOS file system because a \ is an escape in a string. To specifiy file c:\root\file.c: -

    -
    -
    
    +
         char file[] = "c:\\root\\file.c"; 
    -

    + This gets even more unpleasant with regular expressions. Consider the escape sequence to match a quoted string: -

    -
    -
    
    +
         /"[^\\]*(\\.[^\\]*)*"/
    -

    +

    In C, this horror is expressed as: -

    -
    -
    
    +
         char quoteString[] = "\"[^\\\\]*(\\\\.[^\\\\]*)*\"";
    -

    +

    The D Way

    Within strings, it is WYSIWYG (what you see is what you get). Escapes are in separate strings. So: -

    -
    -
    
    +
         char[] file = 'c:\root\file.c'; 
         char[] quoteString = \"  r"[^\\]*(\\.[^\\]*)*"  \";
    -

    + The famous hello world string becomes: -

    -
    -
    
    +
         char[] hello = "hello world" \n; 
    -

    +


    @@ -1100,30 +1022,24 @@

    The C Way

    C uses the wchar_t and the L prefix on strings: -

    -
    -
    
    +
         #include <wchar.h> 
         char foo_ascii[] = "hello"; 
         wchar_t foo_wchar[] = L"hello"; 
    -

    + Things get worse if code is written to be both ascii and wchar compatible. A macro is used to switch strings from ascii to wchar: -

    -
    -
    
    +
         #include <tchar.h> 
         tchar string[] = TEXT("hello"); 
    -

    +

    The D Way

    The type of a string is determined by semantic analysis, so there is no need to wrap strings in a macro call: -

    -
    -
    
    +
         char[] foo_ascii = "hello";            // string is taken to be ascii 
         wchar[] foo_wchar = "hello";       // string is taken to be wchar 
    -

    +


    @@ -1132,18 +1048,14 @@

    The C Way

    Consider: -

    -
    -
    
    +
            enum COLORS { red, blue, green, max }; 
            char *cstring[max] = {"red", "blue", "green" }; 
    -

    + This is fairly easy to get right because the number of entries is small. But suppose it gets to be fairly large. Then it can get difficult to maintain correctly when new entries are added.

    The D Way

    -

    -
    -
    
    +
        enum COLORS { red, blue, green }
     
         char[][COLORS.max + 1] cstring = 
    @@ -1152,7 +1064,7 @@
     	COLORS.blue  : "blue", 
     	COLORS.green : "green",
         ]; 
    -

    + Not perfect, but better. @@ -1166,9 +1078,7 @@ a new type. The compiler doesn't distinguish between a typedef and its underlying type. -

    -
    -
    
    +	
     	typedef void *Handle;
     	void foo(void *);
     	void bar(Handle);
    @@ -1176,14 +1086,12 @@
     	Handle h;
     	foo(h);			// coding bug not caught
     	bar(h);			// ok
    -	

    + The C solution is to create a dummy struct whose sole purpose is to get type checking and overloading on the new type. -

    -
    -
    
    +	
     	struct Handle__ { void *value; }
     	typedef struct Handle__ *Handle;
     	void foo(void *);
    @@ -1192,27 +1100,23 @@
     	Handle h;
     	foo(h);			// syntax error
     	bar(h);			// ok
    -	

    + Having a default value for the type involves defining a macro, a naming convention, and then pedantically following that convention: -

    -
    -
    
    +	
     	#define HANDLE_INIT ((Handle)-1)
     
     	Handle h = HANDLE_INIT;
     	h = func();
     	if (h != HANDLE_INIT)
     	    ...
    -	

    + For the struct solution, things get even more complex: -

    -
    -
    
    +	
     	struct Handle__ HANDLE_INIT;
     
     	void init_handle()	// call this function upon startup
    @@ -1224,7 +1128,7 @@
     	h = func();
     	if (memcmp(&h,&HANDLE_INIT,sizeof(Handle)) != 0)
     	    ...
    -	

    + There are 4 names to remember: Handle, HANDLE_INIT, struct Handle__, value. @@ -1233,9 +1137,7 @@ No need for idiomatic constructions like the above. Just write: -

    -
    -
    
    +	
     	typedef void* Handle;
     	void foo(void*);
     	void bar(Handle);
    @@ -1243,20 +1145,18 @@
     	Handle h;
     	foo(h);
     	bar(h);
    -	

    + To handle a default value, add an initializer to the typedef, and refer to it with the .init property: -

    -
    -
    
    +	
     	typedef void* Handle = cast(void*)(-1);
     	Handle h;
     	h = func();
     	if (h != Handle.init)
     	    ...
    -	

    + There's only one name to remember: Handle. @@ -1268,27 +1168,23 @@ While C defines struct assignment in a simple, convenient manner: -

    -
    -
    
    +	
     	struct A x, y;
     	...
     	x = y;
    -	

    + it does not for struct comparisons. Hence, to compare two struct instances for equality: -

    -
    -
    
    +	
     	#include <string.h>
     
     	struct A x, y;
     	...
     	if (memcmp(&x, &y, sizeof(struct A)) == 0)
     	    ...
    -	

    + Note the obtuseness of this, coupled with the lack of any kind of help from the language with type checking. @@ -1304,14 +1200,12 @@ D does it the obvious, straightforward way: -

    -
    -
    
    +	
     	A x, y;
     	...
     	if (x == y)
     	    ...
    -	

    +


    @@ -1320,14 +1214,12 @@

    The C Way

    The library function strcmp() is used: -

    -
    -
    
    +	
     	char string[] = "hello";
     
     	if (strcmp(string, "betty") == 0)	// do strings match?
     	    ...
    -	

    + C uses 0 terminated strings, so the C way has an inherent inefficiency in constantly scanning for the terminating 0. @@ -1336,14 +1228,12 @@ Why not use the == operator? -

    -
    -
    
    +	
     	char[] string = "hello";
     
     	if (string == "betty")
     	    ...
    -	

    + D strings have the length stored separately from the string. Thus, the implementation of string compares can be much faster @@ -1353,14 +1243,12 @@ D supports comparison operators on strings, too: -

    -
    -
    
    +	
     	char[] string = "hello";
     
     	if (string < "betty")
     	    ...
    -	

    + which is useful for sorting/searching. @@ -1372,9 +1260,7 @@ Although many C programmers tend to reimplmement bubble sorts over and over, the right way to sort in C is to use qsort(): -

    -
    -
    
    +	
     	int compare(const void *p1, const void *p2)
     	{
     	    type *t1 = (type *)p1;
    @@ -1387,7 +1273,7 @@
     	...
     	qsort(array, sizeof(array)/sizeof(array[0]),
     		sizeof(array[0]), compare);
    -	

    + A compare() must be written for each type, and much careful typo-prone code needs to be written to make it work. @@ -1397,13 +1283,11 @@ Sorting couldn't be easier: -

    -
    -
    
    +	
     	type[] array;
     	...
     	array.sort;		// sort array in-place
    -	

    +


    Volatile memory access

    @@ -1412,25 +1296,21 @@ To access volatile memory, such as shared memory or memory mapped I/O, a pointer to volatile is created: -

    -
    -
    
    +	
     	volatile int *p = address;
     
     	i = *p;
    -	

    +

    The D Way

    D has volatile as a statement type, not as a type modifier: -

    -
    -
    
    +	
     	int* p = address;
     
     	volatile { i = *p; }
    -	

    +


    String literals

    @@ -1440,13 +1320,11 @@ String literals in C cannot span multiple lines, so to have a block of text it is necessary to use \ line splicing: -

    -
    -
    
    +	
     	"This text spans\n
     	multiple\n
     	lines\n"
    -	

    + If there is a lot of text, this can wind up being tedious. @@ -1454,14 +1332,12 @@ String literals can span multiple lines, as in: -

    -
    -
    
    +	
     	"This text spans
     	multiple
     	lines
     	"
    -	

    + So blocks of text can just be cut and pasted into the D source. @@ -1485,9 +1361,7 @@ some context outside of the trees, so a custom struct Paramblock is created and a pointer to it is used to maximize efficiency. -

    -
    -
    
    +    
         struct Symbol
         {	char *id;
     	struct Symbol *left;
    @@ -1529,7 +1403,7 @@
     	}
     	return pb.sm;
         }
    -    

    +

    The D Way

    @@ -1543,9 +1417,7 @@ The performance of the two versions is indistinguishable. -

    -
    -
    
    +    
         class Symbol
         {	char[] id;
     	Symbol left;
    @@ -1578,7 +1450,7 @@
     	}
     	return sm;
         }
    -    

    +


    Unsigned Right Shift

    @@ -1591,24 +1463,20 @@ integral type. To produce an unsigned right shift on an int, a cast is necessary: -

    -
    -
    
    +	
     	int i, j;
     	...
     	j = (unsigned)i >> 3;
    -	

    + If i is an int, this works fine. But if i is of a typedef'd type, -

    -
    -
    
    +	
     	myint i, j;
     	...
     	j = (unsigned)i >> 3;
    -	

    + and myint happens to be a long int, then the cast to unsigned @@ -1623,13 +1491,11 @@ do an unsigned right shift regardless of the sign of the left operand. Hence, -

    -
    -
    
    +	
     	myint i, j;
     	...
     	j = i >>> 3;
    -	

    + avoids the unsafe cast and will work as expected with any integral type. @@ -1651,9 +1517,7 @@ class that holds an array of int's, and a user of that container that computes the maximum of those int's. -

    -
    -
    
    +	
     	struct Collection
     	{
     	    int array[10];
    @@ -1679,7 +1543,7 @@
     
     	    c->apply(&max, comp_max);
     	}
    -	

    + The C way makes heavy use of pointers and casting. The casting is tedious, error prone, and loses all type safety. @@ -1691,9 +1555,7 @@ and nested functions both to capture context information and to improve locality. -

    -
    -
    	class Collection
    +	
    	class Collection
     	{
     	    int[10] array;
     
    @@ -1715,20 +1577,18 @@
     	    }
     
     	    c.apply(comp_max);
    -	}

    + } Pointers are eliminated, as well as casting and generic pointers. The D version is fully type safe. An alternate method in D makes use of function literals: -

    -
    -
    	void func(Collection c)
    +	
    	void func(Collection c)
     	{
     	    int max = int.min;
     
     	    c.apply(delegate(int i) { if (i > max) max = i; } );
    -	}

    + } eliminating the need to create irrelevant function names. @@ -1741,9 +1601,7 @@

    The C Way

    -

    -
    -
    
    +	
     	#include <stdio.h>
     	#include <stdarg.h>
     
    @@ -1768,7 +1626,7 @@
     
     	    return 0;
     	} 
    -	

    + There are two problems with this. The first is that the sum function needs to know how many arguments were @@ -1787,9 +1645,7 @@ type, and the number of arguments becomes a property of the array: -

    -
    -
    
    +	
     	int sum(int[] values ...)
     	{
     	    int s = 0;
    @@ -1808,18 +1664,18 @@
     
     	    return 0;
     	}
    -	

    + +

    Feedback and Comments

    - Add Add feedback and comments regarding this - page. + page.

    -
    -Copyright © 1999-2005 by Digital Mars, All Rights Reserved

    +

    -
    diff -uNr dmd-0.129/dmd/html/d/dbc.html dmd-0.130/dmd/html/d/dbc.html --- dmd-0.129/dmd/html/d/dbc.html 2005-05-19 15:08:50.000000000 +0200 +++ dmd-0.130/dmd/html/d/dbc.html 2005-08-26 11:54:10.000000000 +0200 @@ -12,9 +12,15 @@ - - + + + + + + + + + - + D Programming Language - Contract Programming + - - + www.digitalmars.com Home | Search | D +| Comments
    -Last update Thu May 19 2005 +Last update Fri Aug 26 2005
    + + + +
    +
    +
    + + + + + +
    +D
    +Language
    +Phobos
    +Comparisons +
    +
    +Lexical
    Modules
    Declarations
    Types
    Properties
    Attributes
    Pragmas
    Expressions
    Statements
    Arrays
    Structs & Unions
    Classes
    Interfaces
    Enums
    Functions
    Operator Overloading
    Templates
    Mixins
    Contracts
    Conditional Compilation
    Handling errors
    Garbage Collection
    Memory Management
    Floating Point
    Inline Assembler
    Interfacing To C
    Portability Guide
    Embedding D in HTML
    Named Character Entities
    Application Binary Interface
    +
    +
    +

    Contract Programming

    @@ -77,11 +138,9 @@ assert. An assert inserts a checkable expression into the code, and that expression must evaluate to true: -

    -
    -
    
    +
     	assert(expression);
    -

    + C programmers will find it familiar. Unlike C, however, an assert in function bodies works by throwing an AssertException, @@ -97,9 +156,7 @@ would be in validating the return value of a function and of any side effects it has. The syntax is: -

    -
    -
    
    +
     	in
     	{
     	    ...contract preconditions...
    @@ -112,7 +169,7 @@
     	{
     	    ...code...
     	}
    -

    + By definition, if a pre contract fails, then the body received bad parameters. An InException is thrown. If a post contract fails, then there is a bug in the body. An OutException is thrown. @@ -122,9 +179,7 @@ body, the variable result is declared and assigned the return value of the function. For example, let's implement a square root function: -

    -
    -
    
    +
     	long square_root(long x)
     	    in
     	    {
    @@ -138,7 +193,7 @@
     	    {
     		return math.sqrt(x);
     	    }
    -

    + The assert's in the in and out bodies are called contracts. Any other D statement or expression is allowed in the bodies, but it is important @@ -151,9 +206,7 @@ If the function returns a void, there is no result, and so there can be no result declaration in the out clause. In that case, use: -

    -
    -
    
    +
     	void func()
     	   out
     	   {
    @@ -163,7 +216,7 @@
     	   {
     		...
     	   }
    -

    + In an out statement, result is initialized and set to the return value of the function.

    @@ -173,9 +226,7 @@

    The in-out statement can also be used inside a function, for example, it can be used to check the results of a loop: -

    -
    -
    
    +
     	in
     	{
     	    assert(j == 0);
    @@ -189,7 +240,7 @@
     	    for (i = 0; i < 10; i++)
     		j++;
     	}
    -

    + This is not implemented at this time.

    In, Out and Inheritance

    @@ -211,26 +262,22 @@ A function can specify the errors it can generate. Since the D way to handle errors is via exceptions, a function declaration lists the exceptions it can generate with the exception specification: -

    -
    -
    
    +
     	void func()
     	    throw (FuncException, BlahException)
     	{
     	    ...
     	}
    -

    + If there is no exception specification, a function can throw any exception. If there is an empty exception specification: -

    -
    -
    
    +
     	void func()
     	    throw()
     	{
     	    ...
     	}
    -

    + then the function is defined to not throw any exceptions. If a function throws an exception when it is defined to not throw any exceptions, the program will be aborted. @@ -253,15 +300,15 @@ Contracts Reading List
    Adding Contracts to Java
    +

    Feedback and Comments

    - Add Add feedback and comments regarding this - page. + page.

    -
    -Copyright © 1999-2005 by Digital Mars, All Rights Reserved

    +

    -
    diff -uNr dmd-0.129/dmd/html/d/dcompiler.html dmd-0.130/dmd/html/d/dcompiler.html --- dmd-0.129/dmd/html/d/dcompiler.html 2005-07-30 20:50:54.000000000 +0200 +++ dmd-0.130/dmd/html/d/dcompiler.html 2005-08-26 11:54:10.000000000 +0200 @@ -12,9 +12,15 @@ - - + + + + + + + + + - + D Programming Language - DMD Compiler + - - + www.digitalmars.com Home | Search | D +| Comments
    -Last update Sat Jul 30 2005 +Last update Fri Aug 26 2005
    + + + +
    +
    +
    + + + + + +
    +D
    +Language
    +Phobos
    +Comparisons +
    +
    + + · Overview
    + · D for Win32
    + · Win32 DLLs in D
    + · C .h to D Modules
    + · FAQ
    + · Style Guide
    + · Example: wc
    + · Future
    + · D Change Log
    + · Tech Tips
    + · Glossary
    + · Acknowledgements
    +
    + Tools +
    + · DMD D Compiler
    + · GDC D Compiler
    + · Linker
    + · Profiler
    +
    + Community +
    + · News Digest
    + · News
    + · Forum
    + · Announcements
    + · Learn
    + · D links
    +
    + Archives +
    + · digitalmars.D
    + · digitalmars.D.dtl
    + · digitalmars.D.announce
    + · digitalmars.D.learn
    + · digitalmars.D.bugs
    + · D.gnu
    + · Old D
    +
    +
    +
    +

    Compiler for D Programming Language

    @@ -555,15 +625,15 @@ and most especially donated code! Join the fray in the D forum. +

    Feedback and Comments

    - Add Add feedback and comments regarding this - page. + page.

    -
    -Copyright © 1999-2005 by Digital Mars, All Rights Reserved

    +

    -
    diff -uNr dmd-0.129/dmd/html/d/declaration.html dmd-0.130/dmd/html/d/declaration.html --- dmd-0.129/dmd/html/d/declaration.html 2005-06-25 10:55:52.000000000 +0200 +++ dmd-0.130/dmd/html/d/declaration.html 2005-08-26 11:54:10.000000000 +0200 @@ -12,9 +12,15 @@ - - + + + + + + + + + - + D Programming Language - Declarations + - - + www.digitalmars.com Home | Search | D +| Comments
    -Last update Sat Jun 25 2005 +Last update Fri Aug 26 2005
    + + + +
    +
    +
    + + + + + +
    +D
    +Language
    +Phobos
    +Comparisons +
    +
    +Lexical
    Modules
    Declarations
    Types
    Properties
    Attributes
    Pragmas
    Expressions
    Statements
    Arrays
    Structs & Unions
    Classes
    Interfaces
    Enums
    Functions
    Operator Overloading
    Templates
    Mixins
    Contracts
    Conditional Compilation
    Handling errors
    Garbage Collection
    Memory Management
    Floating Point
    Inline Assembler
    Interfacing To C
    Portability Guide
    Embedding D in HTML
    Named Character Entities
    Application Binary Interface
    +
    +
    + + +

    Declarations

    + +
    +Declaration:
    +        typedef Decl
    +        alias Decl
    +        Decl
    +
    +Decl:
    +        StorageClass Decl
    +        BasicType Declarators ;
    +        BasicType Declarator FunctionBody
    +
    +Declarators:
    +        DeclaratorInitializer
    +        DeclaratorInitializer , DeclaratorIdentifierList
    +
    +DeclaratorInitializer:
    +        Declarator
    +        Declarator = Initializer
    +
    +DeclaratorIdentifierList:
    +        DeclaratorIdentifier
    +        DeclaratorIdentifier , DeclaratorIdentifierList
    +
    +DeclaratorIdentifier:
    +        Identifier
    +        Identifier = Initializer
    +
    +BasicType:
    +        bit
    +        byte
    +        ubyte
    +        short
    +        ushort
    +        int
    +        uint
    +        long
    +        ulong
    +        char
    +        wchar
    +        dchar
    +        float
    +        double
    +        real
    +        ifloat
    +        idouble
    +        ireal
    +        cfloat
    +        cdouble
    +        creal
    +        void
    +        .IdentifierList
    +        IdentifierList
    +        Typeof
    +        Typeof . IdentifierList
    +
    +BasicType2:
    +        *
    +        [ ]
    +        [ Expression ]
    +        [ Type ]
    +        delegate ( ParameterList )
    +        function ( ParameterList )
    +
    +Declarator:
    +        BasicType2 Declarator
    +        Identifier
    +        ( Declarator )
    +        Identifier DeclaratorSuffixes
    +        ( Declarator ) DeclaratorSuffixes
    +
    +DeclaratorSuffixes:
    +        DeclaratorSuffix
    +        DeclaratorSuffix DeclaratorSuffixes
    +
    +DeclaratorSuffix:
    +        [ ]
    +        [ Expression ]
    +        [ Type ]
    +        ( ParameterList )
    +
    +IdentifierList:
    +        Identifier
    +        Identifier . IdentifierList
    +        TemplateInstance
    +        TemplateInstance . IdentifierList
    +
    +Typeof:
    +        typeof ( Expression )
    +
    +StorageClass:
    +        abstract
    +        auto
    +        const
    +        deprecated
    +        final
    +        override
    +        static
    +        synchronized
    +
    +Type:
    +        BasicType
    +        BasicType Declarator2
    +
    +Declarator2:
    +        BasicType2 Declarator2
    +        ( Declarator2 )
    +        ( Declarator2 ) DeclaratorSuffixes
    +
    +ParameterList:
    +        Parameter
    +        Parameter , ParameterList
    +        ...
    +
    +Parameter:
    +        Declarator
    +        Declarator = AssignExpression
    +        InOut Declarator
    +        InOut Declarator = AssignExpression
    +
    +InOut:
    +        in
    +        out
    +        inout
    +
    +Initializer:
    +        void
    +        AssignExpression
    +        ArrayInitializer
    +        StructInitializer
     
    -

    Declarations

    - -

    -
    -
    
    -	Declaration:
    -		typedef Decl
    -		alias Decl
    -		Decl
    -
    -	Decl:
    -		StorageClass Decl
    -		BasicType Declarators ;
    -		BasicType Declarator FunctionBody
    -
    -	Declarators:
    -		DeclaratorInitializer
    -		DeclaratorInitializer , DeclaratorIdentifierList
    -
    -	DeclaratorInitializer:
    -		Declarator
    -		Declarator = Initializer
    -
    -	DeclaratorIdentifierList:
    -		DeclaratorIdentifier
    -		DeclaratorIdentifier , DeclaratorIdentifierList
    -
    -	DeclaratorIdentifier:
    -		Identifier
    -		Identifier = Initializer
    -
    -	BasicType:
    -		bit
    -		byte
    -		ubyte
    -		short
    -		ushort
    -		int
    -		uint
    -		long
    -		ulong
    -		char
    -		wchar
    -		dchar
    -		float
    -		double
    -		real
    -		ifloat
    -		idouble
    -		ireal
    -		cfloat
    -		cdouble
    -		creal
    -		void
    -		.IdentifierList
    -		IdentifierList
    -		Typeof
    -		Typeof . IdentifierList
    -
    -	BasicType2:
    -		*
    -		[ ]
    -		[ Expression ]
    -		[ Type ]
    -		delegate ( ParameterList )
    -		function ( ParameterList )
    -
    -	Declarator:
    -		BasicType2 Declarator
    -		Identifier
    -		( Declarator )
    -		Identifier DeclaratorSuffixes
    -		( Declarator ) DeclaratorSuffixes
    -
    -	DeclaratorSuffixes:
    -		DeclaratorSuffix
    -		DeclaratorSuffix DeclaratorSuffixes
    -
    -	DeclaratorSuffix:
    -		[ ]
    -		[ Expression ]
    -		[ Type ]
    -		( ParameterList )
    -
    -	IdentifierList
    -		Identifier
    -		Identifier . IdentifierList
    -		TemplateInstance
    -		TemplateInstance . IdentifierList
    -
    -	Typeof
    -		typeof ( Expression )
    -
    -	StorageClass:
    -		abstract
    -		auto
    -		const
    -		deprecated
    -		final
    -		override
    -		static
    -		synchronized
    -
    -	Type:
    -		BasicType
    -		BasicType Declarator2
    -
    -	Declarator2:
    -		BasicType2 Declarator2
    -		( Declarator2 )
    -		( Declarator2 ) DeclaratorSuffixes
    -
    -	ParameterList:
    -		Parameter
    -		Paremeter , ParameterList
    -		...
    -
    -	Parameter:
    -		Declarator
    -		Declarator = AssignExpression
    -		InOut Declarator
    -		InOut Declarator = AssignExpression
    -
    -	InOut:
    -		in
    -		out
    -		inout
    -
    -	Initializer:
    -		void
    -		AssignExpression
    -		ArrayInitializer
    -		StructInitializer
    -
    -	

    +

    Declaration Syntax

    - Declaration syntax generally reads right to left: +

    Declaration syntax generally reads right to left:

    + +
    +int x;		// x is an int
    +int* x;		// x is a pointer to int
    +int** x;	// x is a pointer to a pointer to int
    +int[] x;	// x is an array of ints
    +int*[] x;	// x is an array of pointers to ints
    +int[]* x;	// x is a pointer to an array of ints
    +
    + +

    Arrays read right to left as well:

    + +
    +int[3] x;	// x is an array of 3 ints
    +int[3][5] x;	// x is an array of 5 arrays of 3 ints
    +int[3]*[5] x;	// x is an array of 5 pointers to arrays of 3 ints
    +
    + +

    +Pointers to functions are declared using the function keyword: +

    -

    -
    -
    
    -	int x;		// x is an int
    -	int* x;		// x is a pointer to int
    -	int** x;	// x is a pointer to a pointer to int
    -	int[] x;	// x is an array of ints
    -	int*[] x;	// x is an array of pointers to ints
    -	int[]* x;	// x is a pointer to an array of ints
    -	

    - - Arrays read right to left as well: - -

    -
    -
    
    -	int[3] x;	// x is an array of 3 ints
    -	int[3][5] x;	// x is an array of 5 arrays of 3 ints
    -	int[3]*[5] x;	// x is an array of 5 pointers to arrays of 3 ints
    -	

    - - Pointers to functions are declared using the function keyword: - -

    -
    -
    
    -	int function(char) x;	// x is a pointer to a function taking a char argument
    -				// and returning an int
    -	int function(char)[] x;	// x is an array of pointers to functions
    -				// taking a char argument and returning an int
    -	

    - - C-style array declarations may be used as an alternative: - -

    -
    -
    
    -	int x[3];	// x is an array of 3 ints
    -	int x[3][5];	// x is an array of 3 arrays of 5 ints
    -	int (*x[5])[3];	// x is an array of 5 pointers to arrays of 3 ints
    -	int (*x)(char);	// x is a pointer to a function taking a char argument
    +
    +int function(char) x;   // x is a pointer to a function taking a char argument
     			// and returning an int
    -	int (*[] x)(char);	// x is an array of pointers to functions
    -				// taking a char argument and returning an int
    -	

    - - In a declaration declaring multiple symbols, all the declarations - must be of the same type: - -

    -
    -
    
    -	int x,y;	// x and y are ints
    -	int* x,y;	// x and y are pointers to ints
    -	int x,*y;	// error, multiple types
    -	int[] x,y;	// x and y are arrays of ints
    -	int x[],y;	// error, multiple types
    -	

    +int function(char)[] x; // x is an array of pointers to functions + // taking a char argument and returning an int + + +

    +C-style array declarations may be used as an alternative: +

    + +
    +int x[3];	   // x is an array of 3 ints
    +int x[3][5];	   // x is an array of 3 arrays of 5 ints
    +int (*x[5])[3];	   // x is an array of 5 pointers to arrays of 3 ints
    +int (*x)(char);	   // x is a pointer to a function taking a char argument
    +		   // and returning an int
    +int (*[] x)(char); // x is an array of pointers to functions
    +		   // taking a char argument and returning an int
    +
    + +

    +In a declaration declaring multiple symbols, all the declarations +must be of the same type: +

    + +
    +int x,y;	// x and y are ints
    +int* x,y;	// x and y are pointers to ints
    +int x,*y;	// error, multiple types
    +int[] x,y;	// x and y are arrays of ints
    +int x[],y;	// error, multiple types
    +
    -

    Type Defining

    +

    Type Defining

    +

    Strong types can be introduced with the typedef. Strong types are semantically a distinct type to the type checking system, for function overloading, and for the debugger. +

    + +
    +typedef int myint;
    +
    +void foo(int x) { . }
    +void foo(myint m) { . }
    +
    + .
    +myint b;
    +foo(b);	        // calls foo(myint)
    +
    -

    -
    -
    
    -	typedef int myint;
    -
    -	void foo(int x) { . }
    -	void foo(myint m) { . }
    -
    -	.
    -	myint b;
    -	foo(b);		// calls foo(myint)
    -	

    - - Typedefs can specify a default initializer different from the - default initializer of the underlying type: - -

    -
    -
    
    -	typedef int myint = 7;
    -	myint m;		// initialized to 7
    -	

    +Typedefs can specify a default initializer different from the +default initializer of the underlying type: +

    +typedef int myint = 7;
    +myint m;        // initialized to 7
    +
    -

    Type Aliasing

    +

    Type Aliasing

    + +

    It's sometimes convenient to use an alias for a type, such as a shorthand for typing out a long, complex type like a pointer to a function. In D, this is done with the alias declaration: +

    -

    -
    -
    
    -	alias abc.Foo.bar myint;
    -	

    +

    +alias abc.Foo.bar myint;
    +
    +

    Aliased types are semantically identical to the types they are aliased to. The debugger cannot distinguish between them, and there is no difference as far as function overloading is concerned. For example: +

    + +
    +alias int myint;
     
    -	

    -
    -
    
    -	alias int myint;
    -
    -	void foo(int x) { . }
    -	void foo(myint m) { . }	error, multiply defined function foo
    -	

    +void foo(int x) { . } +void foo(myint m) { . } error, multiply defined function foo +

    +

    Type aliases are equivalent to the C typedef. +

    Alias Declarations

    +

    A symbol can be declared as an alias of another symbol. For example: +

    -

    -
    -
    
    -	import string;
    -
    -	alias string.strlen mylen;
    -	...
    -	int len = mylen("hello");	// actually calls string.strlen()
    -	

    +

    +import string;
     
    +alias string.strlen mylen;
    + ...
    +int len = mylen("hello");	// actually calls string.strlen()
    +
    + +

    The following alias declarations are valid: +

    -

    -
    -
    
    -	template Foo2(T) { alias T t; }
    -	alias Foo2!(int) t1;
    -	alias Foo2!(int).t t2;
    -	alias t1.t t3;
    -	alias t2 t4;
    -
    -	t1.t v1;	// v1 is type int
    -	t2 v2;		// v2 is type int
    -	t3 v3;		// v3 is type int
    -	t4 v4;		// v4 is type int
    -	

    +

    +template Foo2(T) { alias T t; }
    +alias Foo2!(int) t1;
    +alias Foo2!(int).t t2;
    +alias t1.t t3;
    +alias t2 t4;
    +
    +t1.t v1;	// v1 is type int
    +t2 v2;		// v2 is type int
    +t3 v3;		// v3 is type int
    +t4 v4;		// v4 is type int
    +
    +

    Aliased symbols are useful as a shorthand for a long qualified symbol name, or as a way to redirect references from one symbol to another: +

    -

    -
    -
    
    -	version (Win32)
    -	{
    -	    alias win32.foo myfoo;
    -	}
    -	version (linux)
    -	{
    -	    alias linux.bar myfoo;
    -	}
    -	

    +

    +version (Win32)
    +{
    +    alias win32.foo myfoo;
    +}
    +version (linux)
    +{
    +    alias linux.bar myfoo;
    +}
    +
    +

    Aliasing can be used to 'import' a symbol from an import into the current scope: -

    -
    -
    
    -	alias string.strlen strlen;
    -	

    +

    + +
    +alias string.strlen strlen;
    +
    +

    Aliases can also 'import' a set of overloaded functions, that can be overloaded with functions in the current scope: +

    + +
    +class A {
    +    int foo(int a) { return 1; }
    +}
    +
    +class B : A {
    +    int foo( int a, uint b ) { return 2; }
    +}
    +
    +class C : B {
    +    int foo( int a ) { return 3; }
    +    alias B.foo foo;
    +}
     
    -	

    -
    -
    
    -	class A {
    -	    int foo(int a) { return 1; }
    -	}
    -
    -	class B : A {
    -	    int foo( int a, uint b ) { return 2; }
    -	}
    -
    -	class C : B {
    -	    int foo( int a ) { return 3; }
    -	    alias B.foo foo;
    -	}
    -
    -	class D : C  {
    -	}
    -
    -
    -	void test()
    -	{
    -	    D b = new D();
    -	    int i;
    -
    -	    i = b.foo(1, 2u);	// calls B.foo
    -	    i = b.foo(1);	// calls C.foo
    -	}
    -	

    +class D : C { +} + +void test() +{ + D b = new D(); + int i; + + i = b.foo(1, 2u); // calls B.foo + i = b.foo(1); // calls C.foo +} +

    + +

    Note: Type aliases can sometimes look indistinguishable from alias declarations: -

    -
    -
    
    -	alias foo.bar abc;	// is it a type or a symbol?
    -	

    +

    + +
    +alias foo.bar abc;	// is it a type or a symbol?
    +
    + +

    The distinction is made in the semantic analysis pass. +

    -

    typeof

    +

    typeof

    +

    Typeof is a way to specify a type based on the type of an expression. For example: +

    -

    -
    -
    
    -	void func(int i)
    -	{
    -	    typeof(i) j;	// j is of type int
    -	    typeof(3 + 6.0) x;	// x is of type double
    -	    typeof(1)* p;	// p is of type pointer to int
    -	    int[typeof(p)] a;	// a is of type int[int*]
    -
    -	    printf("%d\n", typeof('c').sizeof);	// prints 1
    -	    double c = cast(typeof(1.0))j;	// cast j to double
    -	}
    -	

    +

    +void func(int i)
    +{
    +    typeof(i) j;	// j is of type int
    +    typeof(3 + 6.0) x;	// x is of type double
    +    typeof(1)* p;	// p is of type pointer to int
    +    int[typeof(p)] a;	// a is of type int[int*]
    +
    +    printf("%d\n", typeof('c').sizeof);	// prints 1
    +    double c = cast(typeof(1.0))j;	// cast j to double
    +}
    +
    +

    Expression is not evaluated, just the type of it is generated: +

    -

    -
    -
    
    -	void func()
    -	{   int i = 1;
    -	    typeof(++i) j;	// j is declared to be an int, i is not incremented
    -	    printf("%d\n", i);	// prints 1
    -	}
    -	

    +

    +void func()
    +{   int i = 1;
    +    typeof(++i) j;	// j is declared to be an int, i is not incremented
    +    printf("%d\n", i);	// prints 1
    +}
    +
    +

    There are two special cases: typeof(this) will generate the type of what this would be in a non-static member function, even if not in a member function. Analogously, typeof(super) will generate the type of what super would be in a non-static member function. +

    + +
    +class A { }
     
    -	

    -
    -
    
    -	class A { }
    -
    -	class B : A
    -	{
    -	    typeof(this) x;	// x is declared to be a B
    -	    typeof(super) y;	// y is declared to be an A
    -	}
    -
    -	struct C
    -	{
    -	    typeof(this) z;	// z is declared to be a C*
    -	    typeof(super) q;	// error, no super struct for C
    -	}
    +class B : A
    +{
    +    typeof(this) x;	// x is declared to be a B
    +    typeof(super) y;	// y is declared to be an A
    +}
    +
    +struct C
    +{
    +    typeof(this) z;	// z is declared to be a C*
    +    typeof(super) q;	// error, no super struct for C
    +}
     
    -	typeof(this) r;		// error, no enclosing struct or class
    -	

    +typeof(this) r; // error, no enclosing struct or class +

    +

    Where Typeof is most useful is in writing generic template code. +

    +

    Feedback and Comments

    - Add Add feedback and comments regarding this - page. + page.

    -
    -Copyright © 1999-2005 by Digital Mars, All Rights Reserved

    +

    -
    diff -uNr dmd-0.129/dmd/html/d/dlinks.html dmd-0.130/dmd/html/d/dlinks.html --- dmd-0.129/dmd/html/d/dlinks.html 2005-08-06 21:59:06.000000000 +0200 +++ dmd-0.130/dmd/html/d/dlinks.html 2005-08-26 11:54:10.000000000 +0200 @@ -14,9 +14,15 @@ - - + + + + + + + + + - + Digital Mars - The D Programming Language + - - + www.digitalmars.com Home | Search | D +| Comments
    -Last update Sat Aug 06 2005 +Last update Fri Aug 26 2005
    + + + +
    +
    +
    + + + + + +
    +D
    +Language
    +Phobos
    +Comparisons +
    +
    + + · Overview
    + · D for Win32
    + · Win32 DLLs in D
    + · C .h to D Modules
    + · FAQ
    + · Style Guide
    + · Example: wc
    + · Future
    + · D Change Log
    + · Tech Tips
    + · Glossary
    + · Acknowledgements
    +
    + Tools +
    + · DMD D Compiler
    + · GDC D Compiler
    + · Linker
    + · Profiler
    +
    + Community +
    + · News Digest
    + · News
    + · Forum
    + · Announcements
    + · Learn
    + · D links
    +
    + Archives +
    + · digitalmars.D
    + · digitalmars.D.dtl
    + · digitalmars.D.announce
    + · digitalmars.D.learn
    + · digitalmars.D.bugs
    + · D.gnu
    + · Old D
    +
    +
    +
    +

    D Links

    @@ -424,15 +494,15 @@ the links to Digital Mars.

    +

    Feedback and Comments

    - Add Add feedback and comments regarding this - page. + page.

    -
    -Copyright © 1999-2005 by Digital Mars, All Rights Reserved

    +

    -
    diff -uNr dmd-0.129/dmd/html/d/dll.html dmd-0.130/dmd/html/d/dll.html --- dmd-0.129/dmd/html/d/dll.html 2005-05-19 15:08:50.000000000 +0200 +++ dmd-0.130/dmd/html/d/dll.html 2005-08-26 11:54:10.000000000 +0200 @@ -12,9 +12,15 @@ - - + + + + + + + + + - + D Programming Language - Writing Win32 DLLs + - - + www.digitalmars.com Home | Search | D +| Comments
    -Last update Thu May 19 2005 +Last update Fri Aug 26 2005
    + + + +
    +
    +
    + + + + + +
    +D
    +Language
    +Phobos
    +Comparisons +
    +
    + + · Overview
    + · D for Win32
    + · Win32 DLLs in D
    + · C .h to D Modules
    + · FAQ
    + · Style Guide
    + · Example: wc
    + · Future
    + · D Change Log
    + · Tech Tips
    + · Glossary
    + · Acknowledgements
    +
    + Tools +
    + · DMD D Compiler
    + · GDC D Compiler
    + · Linker
    + · Profiler
    +
    + Community +
    + · News Digest
    + · News
    + · Forum
    + · Announcements
    + · Learn
    + · D links
    +
    + Archives +
    + · digitalmars.D
    + · digitalmars.D.dtl
    + · digitalmars.D.announce
    + · digitalmars.D.learn
    + · digitalmars.D.bugs
    + · D.gnu
    + · Old D
    +
    +
    +
    +

    Writing Win32 DLLs in D

    @@ -72,9 +142,7 @@ A DllMain() is required, looking like: -

    -
    -
    
    +	
     import std.c.windows.windows;
     HINSTANCE g_hInst;
     
    @@ -111,7 +179,7 @@
         g_hInst=hInstance;
         return true;
     }
    -	

    + Notes:

      @@ -148,12 +216,10 @@ which prints a string:

      mydll2.d:

      -

      -
      -
      
      +	
       module mydll;
       export void dllprint() { printf("hello dll world\n"); }
      -	

      +

      mydll.def:

      @@ -176,9 +242,7 @@
       	Now for a program, test.d, which will use the dll:
       
       	

      test.d:

      -

      -
      -
      
      +	
       import mydll;
       
       int main()
      @@ -186,16 +250,14 @@
          mydll.dllprint();
          return 0;
       }
      -	

      +

      Create a clone of mydll2.d that doesn't have the function bodies:

      mydll.d:

      -

      -
      -
      
      +	
       export void dllprint();
      -	

      + Compile and link with the command:

      @@ -276,9 +338,7 @@
       
       	So, to write a COM object:
       
      -	

      -
      -
      
      +	
       import std.c.windows.com;
       
       class MyCOMobject : ComObject
      @@ -286,7 +346,7 @@
           extern (Windows):
       	...
       }
      -	

      +

      The sample code includes an example COM client program and server DLL. @@ -313,9 +373,7 @@

      Starting with the code for the DLL, mydll.d: -

      -
      -
      
      +	
       /*
        * MyDll demonstration of how to write D DLLs.
        */
      @@ -407,7 +465,7 @@
       {
           return new MyClass();
       }
      -	

      +

      DllMain @@ -522,9 +580,7 @@ mydll.dll. There are two versions, one statically binds to the DLL, and the other dynamically loads it. -

      -
      -
      
      +	
       import std.stdio;
       import std.gc;
       
      @@ -617,7 +673,7 @@
           c.free(s);
           delete c;
       }
      -	

      + Let's start with the statically linked version, which is simpler. It's compiled and linked with the command: @@ -675,15 +731,15 @@ DLL_PROCESS_DETACH End... +

    Feedback and Comments

    - Add Add feedback and comments regarding this - page. + page.

    -
    -Copyright © 1999-2005 by Digital Mars, All Rights Reserved

    +

    -
    diff -uNr dmd-0.129/dmd/html/d/doc.html dmd-0.130/dmd/html/d/doc.html --- dmd-0.129/dmd/html/d/doc.html 1970-01-01 01:00:00.000000000 +0100 +++ dmd-0.130/dmd/html/d/doc.html 2005-09-06 16:50:56.000000000 +0200 @@ -0,0 +1,543 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Digital Mars - The D Programming Language - EmbeddedDocumentation + + + + +www.digitalmars.com + +Home +| Search +| D +| Comments + +
    +Last update Tue Sep 06 2005 +
    + + + +
    +
    +
    + + + + + +
    +D
    +Language
    +Phobos
    +Comparisons +
    +
    + + · Overview
    + · D for Win32
    + · Win32 DLLs in D
    + · C .h to D Modules
    + · FAQ
    + · Style Guide
    + · Example: wc
    + · Future
    + · D Change Log
    + · Tech Tips
    + · Glossary
    + · Acknowledgements
    +
    + Tools +
    + · DMD D Compiler
    + · GDC D Compiler
    + · Linker
    + · Profiler
    +
    + Community +
    + · News Digest
    + · News
    + · Forum
    + · Announcements
    + · Learn
    + · D links
    +
    + Archives +
    + · digitalmars.D
    + · digitalmars.D.dtl
    + · digitalmars.D.announce
    + · digitalmars.D.learn
    + · digitalmars.D.bugs
    + · D.gnu
    + · Old D
    +
    +
    +
    + + +

    Embedded Documentation

    + + +The D programming language enables embedding both contracts and test +code along side the actual code, which helps to keep them all +consistent with each other. One thing lacking is the documentation, +as ordinary comments are usually unsuitable for automated extraction +and formatting into manual pages. +Embedding the user documentation into the source code has important +advantages, such as not having to write the documentation twice, and +the likelihood of the documentation staying consistent with the code. +

    + +Some existing approaches to this are: + +

    + +D's goals for embedded documentation are: + +
      +
    1. It looks good as embedded documentation, not just after it + is extracted and processed. +
    2. It's easy and natural to write, + i.e. minimal reliance on <tags> and other clumsy forms one + would never see in a finished document. +
    3. It does not repeat information that the compiler already + knows from parsing the code. +
    4. It doesn't rely on embedded HTML, as such will impede + extraction and formatting for other purposes. +
    5. It's based on existing D comment forms, so it + is completely independent of parsers only interested in D code. +
    6. It should look at feel different from code, so it won't + be visually confused with code. +
    7. It should be possible for the user to use Doxygen or other + documentation extractor if desired. +
    + +

    Specification

    + +Note: This is not implemented, it's just a proposal. +

    + +Embedded documentation comments are one of the following forms: + +

      +
    1. /** ... */ The two *'s after the opening / +
    2. /++ ... +/ The two +'s after the opening / +
    3. /// The three slashes +
    + +The following are all embedded documentation comments: + +
    +/// This is a one line documentation comment.
    +
    +/** So is this. */
    +
    +/++ And this. +/
    +
    +/**
    +   This is a brief documentation comment.
    + */
    +
    +/**
    + * The leading * on this line is not part of the documentation comment.
    + */
    +
    +/*********************************
    +   The extra *'s immediately following the /** are not
    +   part of the documentation comment.
    + */
    +
    +/++
    +   This is a brief documentation comment.
    + +/
    +
    +/++
    + + The leading + on this line is not part of the documentation comment.
    + +/
    +
    +/+++++++++++++++++++++++++++++++++
    +   The extra +'s immediately following the /++ are not
    +   part of the documentation comment.
    + +/
    +
    +
    + +The extra *'s and +'s on the comment opening and left margin are ignored +and are not part +of the embedded documentation. +Comments not following one of those forms are not documentation comments. +

    + +Each documentation comment is associated with a declaration. +If the documentation comment is on a line by itself or with only whitespace +to the left, it refers to the next +declaration. +Multiple documentation comments with no intervening declarations +are concatenated. +Documentation comments preceding the ModuleDeclaration apply to the +entire module. +If the documentation comment appears on the same line to the right of a +declaration, it applies to that. +A documentation comment before the ModuleDeclaration applies to the +entire module. + +If a documentation comment for a declaration consists only of the +identifier ditto +then the documentation comment for the previous declaration at the same +scope is applied to this declaration as well. + + +

    +int a;  /// documentation for a; b has no documentation
    +int b;
    +
    +/** documentation for c and d */
    +/** more documentation for c and d */
    +int c;
    +/** ditto */
    +int d;
    +
    +/** documentation for e and f */ int e;
    +int f;	/// ditto
    +
    +/// documentation for C and D
    +class C
    +{
    +    int x;    /// documentation for C.x
    +
    +    /** documentation for C.y and C.z */
    +    int y;
    +    int z;    /// ditto
    +}
    +
    +/// ditto
    +class D
    +{
    +}
    +
    + + + +

    Basic Structure

    + +The first paragraph, up to a blank line or a Section, +of a documentation comment forms the +summary line. Summary lines should be short. +Subsequent paragraphs form the more detailed description. +Paragraphs are delineated by blank lines or Sections. + +
    +/***********************************
    + * Brief summary of what
    + * myfunc does.
    + *
    + * First paragraph of fuller description.
    + *
    + * Second paragraph of
    + * fuller description.
    + */
    +
    +void myfunc() { }
    +
    + +Function parameters can be documented by associating a comment with each +parameter: + +
    +/***********************************
    + * foo does this.
    + */
    +
    +void foo(
    +	int x,  /// is for this
    +	int y   /// is for that
    +	)
    +{
    +}
    +
    + + +

    Hyperlinks

    + +Hyperlinks and email addresses can just be inserted as is, the documentation +extractor will convert them into HTML hyperlinks as necessary: + +
    +/** For more information mail to foo@bar.com or look
    +    at the website http://www.bar.com.
    +  */
    +
    + + +

    Embedded HTML

    + +HTML can be embedded into the documentation comments, and it will +be passed through to the HTML output unchanged. +However, since it is not necessarily true that HTML will be the desired +output format of the embedded documentation comment extractor, it is +best to avoid using it where practical. + +
    +/** Example of embedded HTML:
    + *   <ol>
    + *      <li> <a href="www.digitalmars.com">Digital Mars</a>
    + *      <li> <a href="www.classicempire.com">Empire</a>
    + *   </ol>
    + */
    +
    + + +

    Emphasis

    + +Identifiers in documentation comments that are function parameters or are +names that are in scope at the associated declaration are emphasized in +the output. +This emphasis can take the form of italics, boldface, a hyperlink, etc. +How it is emphasized depends on what it is - a function parameter, type, +D keyword, etc. +To prevent unintended emphasis of an identifier, it can be preceded by +an underscore (_). The underscore will be stripped from the output. + +

    Sections

    + +Additional, more specific information can be delineated with Sections. +Sections start with an identifier being the first non-whitespace on a +line, immediately followed by a colon ":". +They are optional and case-insensitive. +The section continues until either the end of the documentation comment +or another section. +Unrecognized sections are passed through to the output unchanged. + +

    Author:

    + +Specifies the name of the author. + +
    +/**
    + * Author: Melvin D. Nerd
    + */
    +
    + + +

    Code:

    + +Used for embedding example D code. Because D code can contain comments, +the /++ ... +/ should probably be the documentation comment used for +code sections. + +
    +/+++++++++++++++++++++++++
    + + Code:
    + +	int func()
    + +	{
    + +	    return 3;   /* the value */
    + +	}
    + +/
    +
    + + +

    Date:

    + +Specifies the date of the last revision. The date should be in a form +parseable by std.date. + +
    +/**
    + * Date: March 14, 2003
    + */
    +
    + + +

    Deprecated:

    + +Provides an explanation for and corrective action to take if the associated +declaration is marked as deprecated. + +
    +/**
    + * Deprecated: superseded by function bar().
    + */
    +
    +deprecated void foo() { ... }
    +
    + + +

    Include:

    + +Specifies a file to be inserted verbatim into the output +of the documentation processor. The file can contain additional documentation, +or things like boilerplate. + +
    +/**
    + * Include: boilerplate.txt
    + */
    +
    + + +

    License:

    + +Specifies the license. + +

    Keywords:

    + +Keywords are added to the list of identifiers to be emphasized. +They only apply to the current documentation comments or to +documentation comments nested within the scope of the associated declaration. + +
    +/**
    + * This cow will be emphasized.
    + * Keywords: fread, fwrite, cow
    + */
    +class A
    +{
    +    /** A, x and cow will be emphasized */
    +    int x;
    +}
    +
    +/**
    + * This cow won't be emphasized.
    + */
    +class B { }
    +
    + + +

    Params:

    + +This is an alternate method of documenting a function's parameters. +The first identifier of each subsequent line is taken to be a parameter name, +followed by its description. Multiple description lines are lined up with +the start of the first description line. + +
    +/** This is my function.
    + * Params:
    + *     fp    File pointer
    + *     name  File name and
    + *           more.
    + */
    +
    +void foo(FILE *fp, char[] name)
    +{
    +    ..
    +}
    +
    + + +

    Returns:

    + +Explains the return value of the function. +If the function returns void, don't redundantly document it. + +
    +/**
    + * Read the file.
    + * Returns: The contents of the file.
    + */
    +
    +void[] readFile(char[] filename) { ... }
    +
    + + +

    URL:

    + +In order for hyperlinks to symbols outside of the current module, +the documentation extractor must know the URL where they will be +located. The URL section is a list of pairs of module names and URL +prefixes. + +
    +import std.string;
    +/**
    + * Thid identifier toupper will be replaced by a hyperlink to
    + * http://www.digitalmars.com/d/phobos/std_string.html#toupper.
    + *
    + * URL:
    + *    std.string  http://www.digitalmars.com/d/phobos/std_string.html
    + */
    +
    + + +

    Version:

    + +Specifies the version. + +
    +/**
    + * Version: 1.6a
    + */
    +
    + + + +
    +

    Feedback and Comments

    + +

    Add feedback and comments regarding this + page.

    + + + + + + + + + + + + + diff -uNr dmd-0.129/dmd/html/d/dstyle.html dmd-0.130/dmd/html/d/dstyle.html --- dmd-0.129/dmd/html/d/dstyle.html 2005-05-19 15:08:50.000000000 +0200 +++ dmd-0.130/dmd/html/d/dstyle.html 2005-08-26 11:54:10.000000000 +0200 @@ -12,9 +12,15 @@ - - + + + + + + + + + - + D Programming Language - The D Style + - - + www.digitalmars.com Home | Search | D +| Comments
    -Last update Thu May 19 2005 +Last update Fri Aug 26 2005
    + + + +
    +
    +
    + + + + + +
    +D
    +Language
    +Phobos
    +Comparisons +
    +
    + + · Overview
    + · D for Win32
    + · Win32 DLLs in D
    + · C .h to D Modules
    + · FAQ
    + · Style Guide
    + · Example: wc
    + · Future
    + · D Change Log
    + · Tech Tips
    + · Glossary
    + · Acknowledgements
    +
    + Tools +
    + · DMD D Compiler
    + · GDC D Compiler
    + · Linker
    + · Profiler
    +
    + Community +
    + · News Digest
    + · News
    + · Forum
    + · Announcements
    + · Learn
    + · D links
    +
    + Archives +
    + · digitalmars.D
    + · digitalmars.D.dtl
    + · digitalmars.D.announce
    + · digitalmars.D.learn
    + · digitalmars.D.bugs
    + · D.gnu
    + · Old D
    +
    +
    +
    +

    The D Style

    @@ -70,30 +140,24 @@
    • Use // comments to document a single line: -

      -
      -
      
      +	
       	    statement;	// comment
       	    statement;	// comment
      -	

      +

    • Use block comments to document a multiple line block of statements: -

      -
      -
      
      +	
       	    /*
       	     * comment
       	     * comment
       	     */
       	     statement;
       	     statement;
      -	

      +

    • Use nesting comments to 'comment out' a piece of trial code: -

      -
      -
      
      +	
       	/+++++
       	    /*
       	     * comment
      @@ -102,7 +166,7 @@
       	     statement;
       	     statement;
       	 +++++/
      -	

      +

    @@ -113,11 +177,9 @@
    Names formed by joining multiple works should have each word other than the first capitalized. -

    -
    -
    
    +	
     	int myFunc();
    -	

    +

    Module
    Module names are all lower case. This avoids problems dealing @@ -127,33 +189,27 @@
    C Modules
    Modules that are interfaces to C functions go into the "c" package, for example: -

    -
    -
    
    +	
     	import std.c.stdio;
    -	

    + Module names should be all lower case.

    Class, Struct, Union, Enum names
    are capitalized. -

    -
    -
    
    +	
     	class Foo;
     	class FooAndBar;
    -	

    +

    Function names
    Function names are not capitalized. -

    -
    -
    
    +	
     	int done();
     	int doneProcessing();
    -	

    +

    Const names
    Are in all caps. @@ -167,13 +223,11 @@ Things like: -

    -
    -
    
    +	
     	alias void VOID;
     	alias int INT;
     	alias int* pint;
    -	

    + should be avoided. @@ -181,21 +235,17 @@ Since in D the declarations are left-associative, left justify them: -

    -
    -
    
    +	
     	int[] x, y;	// makes it clear that x and y are the same type
     	int** p, q;	// makes it clear that p and q are the same type
    -	

    + to emphasize their relationship. Do not use the C style: -

    -
    -
    
    +	
     	int []x, y;	// confusing since y is also an int[]
     	int **p, q;	// confusing since q is also an int**
    -	

    +

    Operator Overloading

    @@ -211,15 +261,15 @@ Just say no. +

    Feedback and Comments

    - Add Add feedback and comments regarding this - page. + page.

    -
    -Copyright © 1999-2005 by Digital Mars, All Rights Reserved

    +

    -
    diff -uNr dmd-0.129/dmd/html/d/entity.html dmd-0.130/dmd/html/d/entity.html --- dmd-0.129/dmd/html/d/entity.html 2005-05-19 15:08:50.000000000 +0200 +++ dmd-0.130/dmd/html/d/entity.html 2005-08-26 11:54:10.000000000 +0200 @@ -12,9 +12,15 @@ - - + + + + + + + + + - + D Programming Language - Named Character Entities + - - + www.digitalmars.com Home | Search | D +| Comments
    -Last update Thu May 19 2005 +Last update Fri Aug 26 2005
    + + + +
    +
    +
    + + + + + +
    +D
    +Language
    +Phobos
    +Comparisons +
    +
    +Lexical
    Modules
    Declarations
    Types
    Properties
    Attributes
    Pragmas
    Expressions
    Statements
    Arrays
    Structs & Unions
    Classes
    Interfaces
    Enums
    Functions
    Operator Overloading
    Templates
    Mixins
    Contracts
    Conditional Compilation
    Handling errors
    Garbage Collection
    Memory Management
    Floating Point
    Inline Assembler
    Interfacing To C
    Portability Guide
    Embedding D in HTML
    Named Character Entities
    Application Binary Interface
    +
    +
    +

    Named Character Entities

    @@ -319,15 +380,15 @@
    +

    Feedback and Comments

    - Add Add feedback and comments regarding this - page. + page.

    -
    -Copyright © 1999-2005 by Digital Mars, All Rights Reserved

    +

    -
    diff -uNr dmd-0.129/dmd/html/d/enum.html dmd-0.130/dmd/html/d/enum.html --- dmd-0.129/dmd/html/d/enum.html 2005-05-19 15:08:50.000000000 +0200 +++ dmd-0.130/dmd/html/d/enum.html 2005-08-26 11:54:10.000000000 +0200 @@ -12,9 +12,15 @@ - - + + + + + + + + + - + D Programming Language - Enums + - - + www.digitalmars.com Home | Search | D +| Comments
    -Last update Thu May 19 2005 +Last update Fri Aug 26 2005
    + + + +
    +
    +
    + + + + + +
    +D
    +Language
    +Phobos
    +Comparisons +
    +
    +Lexical
    Modules
    Declarations
    Types
    Properties
    Attributes
    Pragmas
    Expressions
    Statements
    Arrays
    Structs & Unions
    Classes
    Interfaces
    Enums
    Functions
    Operator Overloading
    Templates
    Mixins
    Contracts
    Conditional Compilation
    Handling errors
    Garbage Collection
    Memory Management
    Floating Point
    Inline Assembler
    Interfacing To C
    Portability Guide
    Embedding D in HTML
    Named Character Entities
    Application Binary Interface
    +
    +
    +

    Enums - Enumerated Types

    @@ -150,15 +211,15 @@ X x; // x is initialized to 3 +

    Feedback and Comments

    - Add Add feedback and comments regarding this - page. + page.

    -
    -Copyright © 1999-2005 by Digital Mars, All Rights Reserved

    +

    -
    diff -uNr dmd-0.129/dmd/html/d/errors.html dmd-0.130/dmd/html/d/errors.html --- dmd-0.129/dmd/html/d/errors.html 2005-05-19 15:08:50.000000000 +0200 +++ dmd-0.130/dmd/html/d/errors.html 2005-08-26 11:54:10.000000000 +0200 @@ -12,9 +12,15 @@ - - + + + + + + + + + - + D Programming Language - Errors + - - + www.digitalmars.com Home | Search | D +| Comments
    -Last update Thu May 19 2005 +Last update Fri Aug 26 2005
    + + + +
    +
    +
    + + + + + +
    +D
    +Language
    +Phobos
    +Comparisons +
    +
    +Lexical
    Modules
    Declarations
    Types
    Properties
    Attributes
    Pragmas
    Expressions
    Statements
    Arrays
    Structs & Unions
    Classes
    Interfaces
    Enums
    Functions
    Operator Overloading
    Templates
    Mixins
    Contracts
    Conditional Compilation
    Handling errors
    Garbage Collection
    Memory Management
    Floating Point
    Inline Assembler
    Interfacing To C
    Portability Guide
    Embedding D in HTML
    Named Character Entities
    Application Binary Interface
    +
    +
    +

    Error Handling in D

    @@ -242,15 +303,15 @@ --> +

    Feedback and Comments

    - Add Add feedback and comments regarding this - page. + page.

    -
    -Copyright © 1999-2005 by Digital Mars, All Rights Reserved

    +

    -
    diff -uNr dmd-0.129/dmd/html/d/expression.html dmd-0.130/dmd/html/d/expression.html --- dmd-0.129/dmd/html/d/expression.html 2005-06-15 12:43:22.000000000 +0200 +++ dmd-0.130/dmd/html/d/expression.html 2005-08-28 21:46:34.000000000 +0200 @@ -12,9 +12,15 @@ - - + + + + + + + + + - + D Programming Language - Expressions + - - + www.digitalmars.com Home | Search | D +| Comments
    -Last update Wed Jun 15 2005 +Last update Sun Aug 28 2005 +
    + + + +
    +
    +
    + + + + + +
    +D
    +Language
    +Phobos
    +Comparisons +

    +Lexical
    Modules
    Declarations
    Types
    Properties
    Attributes
    Pragmas
    Expressions
    Statements
    Arrays
    Structs & Unions
    Classes
    Interfaces
    Enums
    Functions
    Operator Overloading
    Templates
    Mixins
    Contracts
    Conditional Compilation
    Handling errors
    Garbage Collection
    Memory Management
    Floating Point
    Inline Assembler
    Interfacing To C
    Portability Guide
    Embedding D in HTML
    Named Character Entities
    Application Binary Interface
    +
    +
    +

    Expressions

    @@ -50,9 +111,7 @@ These values can then be assigned, tested, or ignored. Expressions can also have side effects. -

    -
    -
    
    +
     	Expression:
     		AssignExpression
     		AssignExpression , Expression
    @@ -209,7 +268,7 @@
     		nothing
     		*
     		* Stars
    -

    +

    Evaluation Order

    @@ -217,13 +276,11 @@ the components of an expression in any order. It is an error to depend on order of evaluation when it is not specified. For example, the following are illegal: -

    -
    -
    
    +	
     	i = ++i;
     	c = a + (a = b);
     	func(++i, ++i);
    -	

    + If the compiler can determine that the result of an expression is illegally dependent on the order of evaluation, it can issue an error (but is not required to). The ability to detect these kinds @@ -231,11 +288,9 @@

    Expressions

    -

    -
    -
    
    +	
     	AssignExpression , Expression
    -	

    + The left operand of the , is evaluated, then the right operand is evaluated. The type of the expression is the type of the right @@ -244,11 +299,9 @@

    Assign Expressions

    -

    -
    -
    
    +	
     	ConditionalExpression = AssignExpression
    -	

    + The right operand is implicitly converted to the type of the left operand, and assigned to it. The result type is the type @@ -260,9 +313,7 @@

    Assignment Operator Expressions

    -

    -
    -
    
    +	
     	ConditionalExpression += AssignExpression
     	ConditionalExpression -= AssignExpression
     	ConditionalExpression *= AssignExpression
    @@ -274,7 +325,7 @@
     	ConditionalExpression <<= AssignExpression
     	ConditionalExpression >>= AssignExpression
     	ConditionalExpression >>>= AssignExpression
    -	

    + Assignment operator expressions, such as: @@ -292,11 +343,9 @@

    Conditional Expressions

    -

    -
    -
    
    +	
     	OrOrExpression ? Expression : ConditionalExpression
    -	

    + The first expression is converted to bool, and is evaluated. If it is true, then the second expression is evaluated, and @@ -310,11 +359,9 @@

    OrOr Expressions

    -

    -
    -
    
    +	
     	OrOrExpression || AndAndExpression
    -	

    + The result type of an OrOr expression is bool, unless the right operand has type void, when the result is type void. @@ -336,11 +383,9 @@

    AndAnd Expressions

    -

    -
    -
    
    +	
     	AndAndExpression && OrExpression
    -	

    + The result type of an AndAnd expression is bool, unless the right operand has type void, when the result is type void. @@ -369,43 +414,35 @@

    Or Expressions

    -

    -
    -
    
    +	
     	OrExpression | XorExpression
    -	

    + The operands are OR'd together.

    Xor Expressions

    -

    -
    -
    
    +	
     	XorExpression ^ AndExpression
    -	

    + The operands are XOR'd together.

    And Expressions

    -

    -
    -
    
    +	
     	AndExpression & EqualExpression
    -	

    + The operands are AND'd together.

    Equality Expressions

    -

    -
    -
    
    +	
     	EqualExpression == RelExpression
     	EqualExpression != RelExpression
    -	

    + Equality expressions compare the two operands for equality (==) or inequality (!=). @@ -451,12 +488,10 @@

    Identity Expressions

    -

    -
    -
    
    +	
     	EqualExpression is RelExpression
     	EqualExpression !is RelExpression
    -	

    + The is compares for identity. To compare for not identity, use e1 !is e2. @@ -482,9 +517,7 @@

    Relational Expressions

    -

    -
    -
    
    +	
     	RelExpression < ShiftExpression
     	RelExpression <= ShiftExpression
     	RelExpression > ShiftExpression
    @@ -497,7 +530,7 @@
     	RelExpression !>= ShiftExpression
     	RelExpression !< ShiftExpression
     	RelExpression !<= ShiftExpression
    -	

    + First, the integral promotions are done on the operands. The result type of a relational expression is bool. @@ -629,22 +662,18 @@

    In Expressions

    -

    -
    -
    
    +	
     	RelExpression in ShiftExpression
    -	

    + An associative array can be tested to see if an element is in the array: -

    -
    -
    
    +	
     	int foo[char[]];
     	...
     	if ("hello" in foo)
     		...
    -	

    + The in expression has the same precedence as the relational expressions <, <=, @@ -655,13 +684,11 @@

    Shift Expressions

    -

    -
    -
    
    +	
     	ShiftExpression << AddExpression
     	ShiftExpression >> AddExpression
     	ShiftExpression >>> AddExpression
    -	

    + The operands must be integral types, and undergo the usual integral promotions. The result type is the type of the left operand after @@ -677,22 +704,18 @@ It's illegal to shift by more bits than the size of the quantity being shifted: -

    -
    -
    
    +	
     	int c;
     	c << 33;	// error
    -	

    +

    Add Expressions

    -

    -
    -
    
    +	
     	AddExpression + MulExpression
     	AddExpression - MulExpression
     	AddExpression ~ MulExpression
    -	

    + If the operands are of integral types, they undergo integral promotions, and then are brought to a common type using the @@ -715,13 +738,11 @@ and added to the pointer. It is illegal if the second operand modulo 8 is non-zero. -

    -
    -
    
    +	
     	bit* p;
     	p += 1;		// error, 1%8 is non-zero
     	p += 8;		// ok
    -	

    + If the second operand is a pointer, and the first is an integral type, and the operator is +, @@ -733,13 +754,11 @@

    Mul Expressions

    -

    -
    -
    
    +	
     	MulExpression * UnaryExpression
     	MulExpression / UnaryExpression
     	MulExpression % UnaryExpression
    -	

    + The operands must be arithmetic types. They undergo integral promotions, and then are brought to a common type using the @@ -763,9 +782,7 @@

    Unary Expressions

    -

    -
    -
    
    +	
     	& UnaryExpression
     	++ UnaryExpression
     	-- UnaryExpression
    @@ -779,7 +796,7 @@
     	cast ( Type ) UnaryExpression
     	( Type ) . Identifier
     	( Expression )
    -	

    +

    New Expressions

    @@ -791,13 +808,11 @@ To allocate multidimensional arrays, the declaration reads in the same order as the prefix array declaration order. -

    -
    -
    
    +	
     	char[][] foo;	// dynamic array of strings
     	...
    -	foo = new char[][30];	// allocate 30 arrays of strings
    -	

    + foo = new char[][30]; // allocate array of 30 strings + If there is an ( ArgumentList ), then those arguments are passed to the class or struct specific allocator @@ -825,11 +840,9 @@ There is an ambiguity in the grammar, however. Consider: -

    -
    -
    
    +	
     	(foo) - p;
    -	

    + Is this a cast of a dereference of negated p to type foo, or is it p being subtracted from foo? This cannot be resolved without looking up foo in the symbol table to see if it is a @@ -840,20 +853,16 @@ C++ does this by introducing: -

    -
    -
    
    +	
     	dynamic_cast<type>(expression)
    -	

    + which is ugly and clumsy to type. D introduces the cast keyword: -

    -
    -
    
    +	
     	cast(foo) -p;	// cast (-p) to type foo
     	(foo) - p;	// subtract p from foo
    -	

    + cast has the nice characteristic that it is easy to do a textual search for it, and takes some @@ -865,9 +874,7 @@ downcast. This means that it is equivalent to the behavior of the dynamic_cast operator in C++. -

    -
    -
    
    +	
     	class A { ... }
     	class B : A { ... }
     
    @@ -878,14 +885,12 @@
     	     A ax = b;		no cast needed
     	     A ax = cast(A) b;	no runtime check needed for upcast
     	}
    -	

    + In order to determine if an object o is an instance of a class B use a cast: -

    -
    -
    
    +	
     	if (cast(B) o)
     	{
     	    // o is an instance of B
    @@ -894,13 +899,11 @@
     	{
     	    // o is not an instance of B
     	}
    -	

    +

    Postfix Expressions

    -

    -
    -
    
    +	
     	PostfixExpression . Identifier
     	PostfixExpression -> Identifier
     	PostfixExpression ++
    @@ -908,15 +911,13 @@
     	PostfixExpression ( ArgumentList )
     	PostfixExpression [ ArgumentList ]
     	PostfixExpression [ AssignExpression .. AssignExpression ]
    -	

    +

    Index Expressions

    -

    -
    -
    
    +	
     	PostfixExpression [ ArgumentList ]
    -	

    + PostfixExpression is evaluated. if PostfixExpression is an expression of type @@ -928,11 +929,9 @@

    Slice Expressions

    -

    -
    -
    
    +	
     	PostfixExpression [ AssignExpression .. AssignExpression ]
    -	

    + PostfixExpression is evaluated. if PostfixExpression is an expression of type @@ -952,9 +951,7 @@

    Primary Expressions

    -

    -
    -
    
    +	
     	Identifier
     	.Identifier
     	this
    @@ -969,7 +966,7 @@
     	AssertExpression
     	BasicType . Identifier
     	typeid ( Type )
    -	

    +

    .Identifier

    @@ -983,9 +980,7 @@ If a member function is called with an explicit reference to typeof(this), a non-virtual call is made: -

    -
    -
    
    +	
     	class A
     	{
     	    char get() { return 'A'; }
    @@ -1006,7 +1001,7 @@
     	    b.foo();		// returns 'A'
     	    b.bar();		// returns 'B'
     	}
    -	

    +

    super

    @@ -1044,9 +1039,7 @@

    Function Literals

    -

    -
    -
    
    +	
     	FunctionLiteral
     		function FunctionBody
     		function ( ParameterList ) FunctionBody
    @@ -1054,7 +1047,7 @@
     		delegate FunctionBody
     		delegate ( ParameterList ) FunctionBody
     		delegate Type ( ParameterList ) FunctionBody
    -	

    + FunctionLiterals enable embedding anonymous functions and anonymous delegates directly into expressions. @@ -1069,9 +1062,7 @@ For example: -

    -
    -
    
    +	
     	int function(char c) fp;	// declare pointer to a function
     
     	void test()
    @@ -1080,26 +1071,22 @@
     
     	    fp = &foo;
     	}
    -	

    + is exactly equivalent to: -

    -
    -
    
    +	
     	int function(char c) fp;
     
     	void test()
     	{
     	    fp = function int(char c) { return 6;} ;
     	}
    -	

    + And: -

    -
    -
    
    +	
     	int abc(int delegate(long i));
     
     	void test()
    @@ -1108,13 +1095,11 @@
     
     	    abc(&foo);
     	}
    -	

    + is exactly equivalent to: -

    -
    -
    
    +	
     	int abc(int delegate(long i));
     
     	void test()
    @@ -1122,14 +1107,12 @@
     
     	    abc( delegate int(long c) { return 6 + b; } );
     	}
    -	

    + Anonymous delegates can behave like arbitrary statement literals. For example, here an arbitrary statement is executed by a loop: -

    -
    -
    
    +	
     	double test()
     	{   double d = 7.6;
     	    float f = 2.3;
    @@ -1147,7 +1130,7 @@
     
     	    return d + f;
     	}
    -	

    + When comparing with nested functions, the function form is analogous to static @@ -1159,12 +1142,10 @@

    Assert Expressions

    -

    -
    -
    
    +	
     	AssertExpression:
     		assert ( Expression )
    -	

    + Asserts evaluate the expression. If the result is false, an AssertError is thrown. If the result is true, then no @@ -1187,21 +1168,17 @@

    Typeid Expressions

    -

    -
    -
    
    +	
     	TypeidExpression:
     	    typeid ( Type )
    -	

    + Returns an instance of class TypeInfo corresponding to Type.

    IsExpression

    -

    -
    -
    
    +	
     	IsExpression:
     		is ( Type )
     		is ( Type : TypeSpecialization )
    @@ -1220,7 +1197,7 @@
     		enum
     		function
     		delegate
    -	

    + IsExpressions are evaluated at compile time and are used for checking for valid types, comparing types for equivalence, @@ -1253,9 +1230,7 @@ The condition is satisfied if Type is semantically correct (it must be syntactically correct regardless). -

    -
    -
    
    +	
     	alias int func(int);	// func is a alias to a function type
     	void foo()
     	{
    @@ -1268,7 +1243,7 @@
     	    if (is([][]))	// error, [][] is not a syntactically valid type
     		...
     	}
    -	

    +

  • is ( Type : TypeSpecialization )
    The condition is satisfied if Type is semantically @@ -1276,9 +1251,7 @@ or can be implicitly converted to TypeSpecialization. TypeSpecialization is only allowed to be a Type. -

    -
    -
    
    +	
     	alias short bar;
     	void foo(bar x)
     	{
    @@ -1288,7 +1261,7 @@
     	    else
     		printf("not satisfied\n");
     	}
    -	

    +

  • is ( Type == TypeSpecialization )
    The condition is satisfied if Type is semantically @@ -1306,9 +1279,7 @@ delegate then the condition is satisifed if Type is one of those. -

    -
    -
    
    +	
     	alias short bar;
     	typedef char foo;
     	void foo(bar x)
    @@ -1324,16 +1295,14 @@
     	    else
     		printf("not satisfied\n");
     	}
    -	

    +

  • is ( Type Identifier )
    The condition is satisfied if Type is semantically correct. If so, Identifier is declared to be an alias of Type. -

    -
    -
    
    +	
     	alias short bar;
     	void foo(bar x)
     	{
    @@ -1347,7 +1316,7 @@
     					// only be in StaticIfConditions
     		...
     	}
    -	

    +

  • is ( Type Identifier : TypeSpecialization )
    The condition is satisfied if Type is the same as @@ -1357,9 +1326,7 @@ dependent on Identifier, the deduced type. TypeSpecialization is only allowed to be a Type. -

    -
    -
    
    +	
     	alias short bar;
     	alias long* abc;
     	void foo(bar x, abc a)
    @@ -1376,7 +1343,7 @@
     
     	    writefln(typeid(typeof(u));	// prints "long"
     	}
    -	

    + The way the type of Identifier is determined is analogous to the way template parameter types are determined by @@ -1434,9 +1401,7 @@

  • the function type of the delegate
    -

    -
    -
    
    +	
     alias short bar;
     enum E : byte { Emember }
     void foo(bar x, abc a)
    @@ -1448,21 +1413,21 @@
         static if ( is(E V == enum) )	// satisified, E is an enum
     	V x;				// x is declared to be a byte
     }
    -	

    + +

    Feedback and Comments

    - Add Add feedback and comments regarding this - page. + page.

    -
    -Copyright © 1999-2005 by Digital Mars, All Rights Reserved

    +

    -
    diff -uNr dmd-0.129/dmd/html/d/faq.html dmd-0.130/dmd/html/d/faq.html --- dmd-0.129/dmd/html/d/faq.html 2005-07-30 20:52:04.000000000 +0200 +++ dmd-0.130/dmd/html/d/faq.html 2005-08-26 11:54:10.000000000 +0200 @@ -12,9 +12,15 @@ - - + + + + + + + + + - + D Programming Language - FAQ + - - + www.digitalmars.com Home | Search | D +| Comments
    -Last update Sat Jul 30 2005 +Last update Fri Aug 26 2005
    + + + +
    +
    +
    + + + + + +
    +D
    +Language
    +Phobos
    +Comparisons +
    +
    + + · Overview
    + · D for Win32
    + · Win32 DLLs in D
    + · C .h to D Modules
    + · FAQ
    + · Style Guide
    + · Example: wc
    + · Future
    + · D Change Log
    + · Tech Tips
    + · Glossary
    + · Acknowledgements
    +
    + Tools +
    + · DMD D Compiler
    + · GDC D Compiler
    + · Linker
    + · Profiler
    +
    + Community +
    + · News Digest
    + · News
    + · Forum
    + · Announcements
    + · Learn
    + · D links
    +
    + Archives +
    + · digitalmars.D
    + · digitalmars.D.dtl
    + · digitalmars.D.announce
    + · digitalmars.D.learn
    + · digitalmars.D.bugs
    + · D.gnu
    + · Old D
    +
    +
    +
    +

    FAQ

    @@ -285,9 +355,7 @@

    How do I do anonymous struct/unions in D?

    -

    -
    -
    
    +	
     struct Foo
     {
         union { int a; int b; }
    @@ -305,42 +373,36 @@
     	&f.c - &f.a,
     	&f.d - &f.a);
     }
    -

    +


    How do I get printf() to work with strings?

    In C, the normal way to printf a string is to use the %s format: -

    -
    -
    
    +	
     	char s[8];
     	strcpy(s, "foo");
     	printf("string = '%s'\n", s);
    -	

    + Attempting this in D, as in: -

    -
    -
    
    +	
     	char[] s;
     	s = "foo";
     	printf("string = '%s'\n", s);
    -	

    + usually results in garbage being printed, or an access violation. The cause is that in C, strings are terminated by a 0 character. The %s format prints until a 0 is encountered. In D, strings are not 0 terminated, the size is determined by a separate length value. So, strings are printf'd using the %.*s format: -

    -
    -
    
    +	
     	char[] s;
     	s = "foo";
     	printf("string = '%.*s'\n", s);
    -	

    + which will behave as expected. Remember, though, that printf's %.*s will print until the length is reached or a 0 is encountered, so D strings with embedded 0's @@ -352,11 +414,9 @@ A floating point value, if no explicit initializer is given, is initialized to nan (Not A Number): -

    -
    -
    
    +	
     	double d;	// d is set to double.nan
    -	

    + Nan's have the interesting property in that whenever a nan is used as an operand in a computation, the result is a nan. Therefore, @@ -506,15 +566,15 @@ --> +

    Feedback and Comments

    - Add Add feedback and comments regarding this - page. + page.

    -
    -Copyright © 1999-2005 by Digital Mars, All Rights Reserved

    +

    -
    diff -uNr dmd-0.129/dmd/html/d/float.html dmd-0.130/dmd/html/d/float.html --- dmd-0.129/dmd/html/d/float.html 2005-05-19 15:08:50.000000000 +0200 +++ dmd-0.130/dmd/html/d/float.html 2005-08-26 11:54:10.000000000 +0200 @@ -12,9 +12,15 @@ - - + + + + + + + + + - + D Programming Language - Floating Point + - - + www.digitalmars.com Home | Search | D +| Comments
    -Last update Thu May 19 2005 +Last update Fri Aug 26 2005 +
    + + + +
    +
    +
    + + + + + +
    +D
    +Language
    +Phobos
    +Comparisons +

    +Lexical
    Modules
    Declarations
    Types
    Properties
    Attributes
    Pragmas
    Expressions
    Statements
    Arrays
    Structs & Unions
    Classes
    Interfaces
    Enums
    Functions
    Operator Overloading
    Templates
    Mixins
    Contracts
    Conditional Compilation
    Handling errors
    Garbage Collection
    Memory Management
    Floating Point
    Inline Assembler
    Interfacing To C
    Portability Guide
    Embedding D in HTML
    Named Character Entities
    Application Binary Interface
    +
    +
    +

    Floating Point

    @@ -100,20 +161,16 @@ Imaginary literals have an i suffix: -

    -
    -
    
    +	
     	ireal j = 1.3i;
    -	

    + There is no particular complex literal syntax, just add a real and imaginary type: -

    -
    -
    
    +	
     	cdouble cd = 3.6 + 4i;
     	creal c = 4.5 + 2i;
    -	

    + Complex numbers have two properties: @@ -182,15 +239,15 @@ !<> F F T T no unordered or equal to +

    Feedback and Comments

    - Add Add feedback and comments regarding this - page. + page.

    -
    -Copyright © 1999-2005 by Digital Mars, All Rights Reserved

    +

    -
    diff -uNr dmd-0.129/dmd/html/d/function.html dmd-0.130/dmd/html/d/function.html --- dmd-0.129/dmd/html/d/function.html 2005-06-08 11:55:42.000000000 +0200 +++ dmd-0.130/dmd/html/d/function.html 2005-08-26 11:54:10.000000000 +0200 @@ -12,9 +12,15 @@ - - + + + + + + + + + - + D Programming Language - Functions + - - + www.digitalmars.com Home | Search | D +| Comments
    -Last update Wed Jun 08 2005 +Last update Fri Aug 26 2005
    + + + +
    +
    +
    + + + + + +
    +D
    +Language
    +Phobos
    +Comparisons +
    +
    +Lexical
    Modules
    Declarations
    Types
    Properties
    Attributes
    Pragmas
    Expressions
    Statements
    Arrays
    Structs & Unions
    Classes
    Interfaces
    Enums
    Functions
    Operator Overloading
    Templates
    Mixins
    Contracts
    Conditional Compilation
    Handling errors
    Garbage Collection
    Memory Management
    Floating Point
    Inline Assembler
    Interfacing To C
    Portability Guide
    Embedding D in HTML
    Named Character Entities
    Application Binary Interface
    +
    +
    +

    Functions

    @@ -66,9 +127,7 @@ derived class, unless they are also private. For example: -

    -
    -
    
    +	
     	class A
     	{
     	    int def() { ... }
    @@ -97,16 +156,14 @@
     	{   B b = new B();
     	    test(b);
     	}
    -	

    + Covariant return types are supported, which means that the overriding function in a derived class can return a type that is derived from the type returned by the overridden function: -

    -
    -
    
    +	
     	class A { }
     	class B : A { }
     
    @@ -119,16 +176,14 @@
     	{
     	    B test() { return null; }	// overrides and is covariant with Foo.test()
     	}
    -	

    +

    Function Inheritance and Overriding

    A functions in a derived class with the same name and parameter types as a function in a base class overrides that function: -

    -
    -
    
    +	
     	class A
     	{
     	    int foo(int x) { ... }
    @@ -149,14 +204,12 @@
     	{
     	    a.foo();	// calls B.foo(int)
     	}
    -	

    + However, when doing overload resolution, the functions in the base class are not considered: -

    -
    -
    
    +	
     	class A
     	{
     	    int foo(int x) { ... }
    @@ -180,14 +233,12 @@
     	    B b = new B();
     	    b.foo(1);		// calls B.foo(long), since A.foo(int) not considered
     	}
    -	

    + To consider the base class's functions in the overload resolution process, use an AliasDeclaration: -

    -
    -
    
    +	
     	class A
     	{
     	    int foo(int x) { ... }
    @@ -212,13 +263,11 @@
     	    B b = new B();
     	    b.foo(1);		// calls A.foo(int)
     	}
    -	

    + A function parameter's default value is not inherited: -

    -
    -
    
    +	
     	class A
     	{
     	    void foo(int x = 5) { ... }
    @@ -246,7 +295,7 @@
     	    C c = new C();
     	    c.foo();		// error, need an argument for C.foo
     	}
    -	

    +

    Inline Functions

    @@ -283,11 +332,9 @@ in is the default; out and inout work like storage classes. For example: -

    -
    -
    
    +	
     	int foo(int x, out int y, inout int z, int q);
    -	

    + x is in, y is out, z is inout, and q is in.

    @@ -311,9 +358,7 @@ out parameters are set to the default initializer for the type of it. For example: -

    -
    -
    
    +	
     	void foo(out int bar)
     	{
     	}
    @@ -321,7 +366,7 @@
     	int bar = 3;
     	foo(bar);
     	// bar is now 0
    -	

    +

    Variadic Functions

    @@ -343,23 +388,19 @@ a parameter of ... after the required function parameters. It has non-D linkage, such as extern (C): -

    -
    -
    
    +	
     	extern (C) int foo(int x, int y, ...);
     
     	foo(3, 4);	// ok
     	foo(3, 4, 6.8);	// ok, one variadic argument
     	foo(2);		// error, y is a required argument
    -	

    + There must have at least one non-variadic parameter declared. -

    -
    -
    
    +	
     	extern (C) int def(...); // error, must have at least one parameter
    -	

    + This kind of function matches the C calling convention for variadic functions, and is most useful for calling C library @@ -372,9 +413,7 @@ arguments. To access the arguments, _argptr must be cast to a pointer to the expected argument type: -

    -
    -
    
    +	
     	foo(3, 4, 5);	// first variadic argument is 5
     
     	int foo(int x, int y, ...)
    @@ -382,17 +421,15 @@
     
     	    z = *cast(int*)_argptr;	// z is set to 5
     	}
    -	

    + To protect against the vagaries of stack layouts on different CPU architectures, use std.c.stdarg to access the variadic arguments: -

    -
    -
    
    +	
     	import std.c.stdarg;
    -	

    +

    Variadic Functions With Type Info

    @@ -401,12 +438,10 @@ It has D linkage, and need not have any non-variadic parameters declared: -

    -
    -
    
    +	
     	int abc(char c, ...);	// one required parameter: c
     	int def(...);		// ok
    -	

    + These variadic functions have a special local variable declared for them, @@ -415,9 +450,7 @@ arguments. To access the arguments, _argptr must be cast to a pointer to the expected argument type: -

    -
    -
    
    +	
     	foo(3, 4, 5);	// first variadic argument is 5
     
     	int foo(int x, int y, ...)
    @@ -425,7 +458,7 @@
     
     	    z = *cast(int*)_argptr;	// z is set to 5
     	}
    -	

    + An additional hidden argument with the name _arguments and type TypeInfo[] @@ -433,9 +466,7 @@ _arguments gives the number of arguments and the type of each, enabling the creation of typesafe variadic functions. -

    -
    -
    
    +	
     	class FOO { }
     
     	void foo(int x, ...)
    @@ -480,13 +511,11 @@
     	    printf("%p\n", f);
     	    foo(1, 2, 3L, 4.5, f);
     	}
    -	

    + which prints: -

    -
    -
    
    +	
     	00870FD0
     	4 arguments
     	int
    @@ -497,15 +526,13 @@
     		4.5
     	FOO
     		00870FD0
    -	

    + To protect against the vagaries of stack layouts on different CPU architectures, use std.stdarg to access the variadic arguments: -

    -
    -
    
    +	
     	import std.stdarg;
     
     	void foo(int x, ...)
    @@ -538,7 +565,7 @@
     		    assert(0);
     	    }
     	}
    -	

    +

    Typesafe Variadic Functions

    @@ -549,9 +576,7 @@ For arrays: -

    -
    -
    
    +	
     	int test()
     	{
     	    return sum(1, 2, 3) + sum(); // returns 6+0
    @@ -570,13 +595,11 @@
     		s += x;
     	    return s;
     	}
    -	

    + For static arrays: -

    -
    -
    
    +	
     	int test()
     	{
     	    return sum(2, 3);	// error, need 3 values for array
    @@ -598,13 +621,11 @@
     		s += x;
     	    return s;
     	}
    -	

    + For class objects: -

    -
    -
    
    +	
     	class Foo { int x; char[] s; }
     
     	void test(int x, Foo f ...);
    @@ -615,15 +636,13 @@
     	test(1, g);		// ok, since g is an instance of Foo
     	test(1, 4, "def");	// ok
     	test(1, 5);		// error, no matching constructor for Foo
    -	

    + An implementation may construct the object or array instance on the stack. Therefore, it is an error to refer to that instance after the variadic function has returned: -

    -
    -
    
    +	
     	Foo test(Foo f ...)
     	{
     	    return f;	// error, f instance contents invalid after return
    @@ -635,13 +654,11 @@
     	    return a[0..1];	// error, array contents invalid after return
     	    return a.dup;	// ok, since copy is made
     	}
    -	

    + For other types, the argument is built with itself, as in: -

    -
    -
    
    +	
     	int test(int i ...)
     	{
     	    return i;
    @@ -652,7 +669,7 @@
     	test(3, 4);	// error, too many arguments
     	int[] x;
     	test(x);	// error, type mismatch
    -	

    +

    Local Variables

    @@ -670,9 +687,7 @@ It is an error to declare a local variable that hides another local variable in the same function: -

    -
    -
    
    +	
     	void func(int x)
     	{   int x;		error, hides previous definition of x
     	     double y;
    @@ -683,7 +698,7 @@
     	     {   wchar z;	legal, previous z is out of scope
     	     }
     	}
    -	

    + While this might look unreasonable, in practice whenever this is done it either is a @@ -700,9 +715,7 @@ Functions may be nested within other functions: -

    -
    -
    
    +	
     	int bar(int a)
     	{
     	    int foo(int b)
    @@ -718,15 +731,13 @@
     	{
     	    int i = bar(3);	// i is assigned 4
     	}
    -	

    + Nested functions can only be accessed by the most nested lexically enclosing function, or by another nested function at the same nesting depth: -

    -
    -
    
    +	
     	int bar(int a)
     	{
     	    int foo(int b) { return b + 1; }
    @@ -739,15 +750,13 @@
     	    int i = bar(3);	// ok
     	    int j = bar.foo(3);	// error, bar.foo not visible
     	}
    -	

    + Nested functions have access to the variables and other symbols defined by the lexically enclosing function. This access includes both the ability to read and write them. -

    -
    -
    
    +	
     	int bar(int a)
     	{   int c = 3;
     
    @@ -766,13 +775,11 @@
     	{
     	    int i = bar(3);	// i is assigned 17
     	}
    -	

    + This access can span multiple nesting levels: -

    -
    -
    
    +	
     	int bar(int a)
     	{   int c = 3;
     
    @@ -786,15 +793,13 @@
     	    }
     	    return foo(3);
     	}
    -	

    + Static nested functions cannot access any stack variables of any lexically enclosing function, but can access static variables. This is analogous to how static member functions behave. -

    -
    -
    
    +	
     	int bar(int a)
     	{   int c;
     	    static int d;
    @@ -807,13 +812,11 @@
     	    }
     	    return foo(a);
     	}
    -	

    + Functions can be nested within member functions: -

    -
    -
    
    +	
     	struct Foo
     	{   int a;
     
    @@ -826,15 +829,13 @@
     		}
     	    }
     	}
    -	

    + Member functions of nested classes and structs do not have access to the stack variables of the enclosing function, but do have access to the other symbols: -

    -
    -
    
    +	
     	void test()
     	{   int j;
     	    static int s;
    @@ -857,7 +858,7 @@
     		}
     	    }
     	}
    -	

    + Nested functions always have the D function linkage type.

    @@ -866,21 +867,17 @@ scope are processed in order. This means that two nested functions cannot mutually call each other: -

    -
    -
    
    +	
     	void test()
     	{
     	    void foo() { bar(); }	// error, bar not defined
     	    void bar() { foo(); }	// ok
     	}
    -	

    + The solution is to use a delegate: -

    -
    -
    
    +	
     	void test()
     	{
     	    void delegate() fp;
    @@ -888,7 +885,7 @@
     	    void bar() { foo(); }
     	    fp = &bar;
     	}
    -	

    + Future directions: This restriction may be removed. @@ -897,9 +894,7 @@ A function pointer can point to a static nested function: -

    -
    -
    
    +	
     	int function() fp;
     
     	void test()
    @@ -914,13 +909,11 @@
     	    test();
     	    int i = fp();	// i is set to 10
     	}
    -	

    + A delegate can be set to a non-static nested function: -

    -
    -
    
    +	
     	int delegate() dg;
     
     	void test()
    @@ -930,22 +923,20 @@
     	    dg = &foo;
     	    int i = dg();	// i is set to 10
     	}
    -	

    + The stack variables, however, are not valid once the function declaring them has exited, in the same manner that pointers to stack variables are not valid upon exit from a function: -

    -
    -
    
    +	
     	int* bar()
     	{   int b;
     	    test();
     	    int i = dg();	// error, test.a no longer exists
     	    return &b;		// error, bar.b not valid after bar() exits
     	}
    -	

    + Delegates to non-static nested functions contain two pieces of data: the pointer to the stack frame of the lexically enclosing @@ -956,9 +947,7 @@ Both forms of delegates are interchangeable, and are actually the same type: -

    -
    -
    
    +	
     	struct Foo
     	{   int a = 7;
     	    int bar() { return a; }
    @@ -979,7 +968,7 @@
     	    i = foo(&abc);	// i is set to 28
     	    i = foo(&f.bar);	// i is set to 8
     	}
    -	

    + This combining of the environment and the function is called a dynamic closure. @@ -992,15 +981,15 @@ See Function Literals. +

    Feedback and Comments

    - Add Add feedback and comments regarding this - page. + page.

    -
    -Copyright © 1999-2005 by Digital Mars, All Rights Reserved

    +

    -
    diff -uNr dmd-0.129/dmd/html/d/future.html dmd-0.130/dmd/html/d/future.html --- dmd-0.129/dmd/html/d/future.html 2005-05-19 15:08:50.000000000 +0200 +++ dmd-0.130/dmd/html/d/future.html 2005-08-26 11:54:10.000000000 +0200 @@ -12,9 +12,15 @@ - - + + + + + + + + + - + D Programming Language - Future Directions + - - + www.digitalmars.com Home | Search | D +| Comments
    -Last update Thu May 19 2005 +Last update Fri Aug 26 2005
    + + + +
    +
    +
    + + + + + +
    +D
    +Language
    +Phobos
    +Comparisons +
    +
    + + · Overview
    + · D for Win32
    + · Win32 DLLs in D
    + · C .h to D Modules
    + · FAQ
    + · Style Guide
    + · Example: wc
    + · Future
    + · D Change Log
    + · Tech Tips
    + · Glossary
    + · Acknowledgements
    +
    + Tools +
    + · DMD D Compiler
    + · GDC D Compiler
    + · Linker
    + · Profiler
    +
    + Community +
    + · News Digest
    + · News
    + · Forum
    + · Announcements
    + · Learn
    + · D links
    +
    + Archives +
    + · digitalmars.D
    + · digitalmars.D.dtl
    + · digitalmars.D.announce
    + · digitalmars.D.learn
    + · digitalmars.D.bugs
    + · D.gnu
    + · Old D
    +
    +
    +
    +

    Future Directions

    @@ -52,15 +122,15 @@
  • Array literal expressions. +
  • Feedback and Comments

    - Add Add feedback and comments regarding this - page. + page.

    -
    -Copyright © 1999-2005 by Digital Mars, All Rights Reserved

    +

    -
    diff -uNr dmd-0.129/dmd/html/d/garbage.html dmd-0.130/dmd/html/d/garbage.html --- dmd-0.129/dmd/html/d/garbage.html 2005-05-19 15:08:50.000000000 +0200 +++ dmd-0.130/dmd/html/d/garbage.html 2005-08-26 11:54:10.000000000 +0200 @@ -12,9 +12,15 @@ - - + + + + + + + + + - + D Programming Language - Garbage Collection + - - + www.digitalmars.com Home | Search | D +| Comments
    -Last update Thu May 19 2005 +Last update Fri Aug 26 2005
    + + + +
    +
    +
    + + + + + +
    +D
    +Language
    +Phobos
    +Comparisons +
    +
    +Lexical
    Modules
    Declarations
    Types
    Properties
    Attributes
    Pragmas
    Expressions
    Statements
    Arrays
    Structs & Unions
    Classes
    Interfaces
    Enums
    Functions
    Operator Overloading
    Templates
    Mixins
    Contracts
    Conditional Compilation
    Handling errors
    Garbage Collection
    Memory Management
    Floating Point
    Inline Assembler
    Interfacing To C
    Portability Guide
    Embedding D in HTML
    Named Character Entities
    Application Binary Interface
    +
    +
    +

    Garbage Collection

    @@ -201,31 +262,25 @@
  • Do not store pointers into non-pointer variables using casts and other tricks. -

    -
    -
    
    +	
     	void* p;
     	...
     	int x = cast(int)p;   // error: undefined behavior
    -	

    + The garbage collector does not scan non-pointer types for roots.

  • Do not take advantage of alignment of pointers to store bit flags in the low order bits: -

    -
    -
    
    +	
     	p = cast(void*)(cast(int)p | 1);  // error: undefined behavior
    -	

    +

  • Do not store into pointers values that may point into the garbage collected heap: -

    -
    -
    
    +	
     	p = cast(void*)12345678;   // error: undefined behavior
    -	

    + A compacting garbage collector may change this value.

    @@ -243,11 +298,9 @@

  • Do not depend on the ordering of pointers: -

    -
    -
    
    +	
     	if (p1 < p2)		// error: undefined behavior
    -	    ...

    + ... since, again, the garbage collector can move objects around in memory.

    @@ -255,24 +308,20 @@

  • Do not add or subtract an offset to a pointer such that the result points outside of the bounds of the garbage collected object originally allocated. -

    -
    -
    
    +	
     	char* p = new char[10];
     	char* q = p + 6;	// ok
     	q = p + 11;		// error: undefined behavior
     	q = p - 1;		// error: undefined behavior
    -	

    +

  • Do not misaligned pointers if those pointers may point into the gc heap, such as: -

    -
    -
    
    +	
     	align (1) struct Foo
     	{   byte b;
     	    char* p;	// misaligned pointer
    -	}

    + } Misaligned pointers may be used if the underlying hardware supports them and the pointer is never used to point into the gc heap. @@ -295,25 +344,21 @@

    • Use a union to share storage with a pointer: -

      -
      -
      
      +	
       	union U { void* ptr; int value }
      -	

      + Using such a union, however, as a substitute for a cast(int) will result in undefined behavior.

    • A pointer to the start of a garbage collected object need not be maintained if a pointer to the interior of the object exists. -

      -
      -
      
      +	
       	char[] p = new char[10];
       	char[] q = p[3..6];
       	// q is enough to hold on to the object, don't need to keep
       	// p as well.
      -	

      +

    @@ -347,15 +392,15 @@ Garbage Collection : Algorithms for Automatic Dynamic Memory Management +
  • Feedback and Comments

    - Add Add feedback and comments regarding this - page. + page.

    -
    -Copyright © 1999-2005 by Digital Mars, All Rights Reserved

    +

    -
    diff -uNr dmd-0.129/dmd/html/d/glossary.html dmd-0.130/dmd/html/d/glossary.html --- dmd-0.129/dmd/html/d/glossary.html 1970-01-01 01:00:00.000000000 +0100 +++ dmd-0.130/dmd/html/d/glossary.html 2005-08-26 11:54:10.000000000 +0200 @@ -0,0 +1,192 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +D Programming Language - Glossary + + + + +www.digitalmars.com + +Home +| Search +| D +| Comments + +
    +Last update Fri Aug 26 2005 +
    + + + +
    +
    +
    + + + + + +
    +D
    +Language
    +Phobos
    +Comparisons +
    +
    + + · Overview
    + · D for Win32
    + · Win32 DLLs in D
    + · C .h to D Modules
    + · FAQ
    + · Style Guide
    + · Example: wc
    + · Future
    + · D Change Log
    + · Tech Tips
    + · Glossary
    + · Acknowledgements
    +
    + Tools +
    + · DMD D Compiler
    + · GDC D Compiler
    + · Linker
    + · Profiler
    +
    + Community +
    + · News Digest
    + · News
    + · Forum
    + · Announcements
    + · Learn
    + · D links
    +
    + Archives +
    + · digitalmars.D
    + · digitalmars.D.dtl
    + · digitalmars.D.announce
    + · digitalmars.D.learn
    + · digitalmars.D.bugs
    + · D.gnu
    + · Old D
    +
    +
    +
    + + + +

    Glossary

    + +
    + +
    COW (Copy On Write) +
    COW is a memory allocation strategy where arrays are copied + if they are to be modified. +

    + +

    GC (Garbage Collection) +
    Garbage collection is the common name for the more highbrow + term automatic memory management. Memory can be allocated and used, + and the GC will automatically free any chunks of memory no longer + referred to. In contrast, C and C++ use explicit memory management + where the programmer must carefully match up each allocation with + one and only one free. +

    + +

    Illegal +
    A code construct is illegal if it does not conform to the + D language specification. + This may be true even if the compiler or runtime fails to detect + the error. +

    + +

    Implementation Defined Behavior +
    This is variation in behavior of the D language in a manner + that is up to the implementor of the language. + An example of implementation defined behavior would be the size in + bytes of a pointer: on a 32 bit machine it would be 4 bytes, on + a 64 bit machine it would be 8 bytes. + Minimizing implementation defined behavior in the language will + maximize the portability of code. +

    + +

    RAII (Resource Acquisition Is Initialization) +
    RAII refers to the technique of having the destructor + of a class object called when the object goes out of scope. + The destructor then releases any resources acquired by + that object. + RAII is commonly used for resources that are in short supply + or that must have a predictable point when they are released. +

    + +

    Undefined Behavior +
    Undefined behavior happens when an illegal code construct is + executed. Undefined behavior can include random, erratic results, + crashes, faulting, etc. +

    + +

    + +
    +

    Feedback and Comments

    + +

    Add feedback and comments regarding this + page.

    + + + + + + + + + + + diff -uNr dmd-0.129/dmd/html/d/html.html dmd-0.130/dmd/html/d/html.html --- dmd-0.129/dmd/html/d/html.html 2005-05-19 15:08:50.000000000 +0200 +++ dmd-0.130/dmd/html/d/html.html 2005-08-26 11:54:10.000000000 +0200 @@ -12,9 +12,15 @@ - - + + + + + + + + + - + D Programming Language - Embedding D in HTML + - - + www.digitalmars.com Home | Search | D +| Comments
    -Last update Thu May 19 2005 +Last update Fri Aug 26 2005
    + + + +
    +
    +
    + + + + + +
    +D
    +Language
    +Phobos
    +Comparisons +
    +
    +Lexical
    Modules
    Declarations
    Types
    Properties
    Attributes
    Pragmas
    Expressions
    Statements
    Arrays
    Structs & Unions
    Classes
    Interfaces
    Enums
    Functions
    Operator Overloading
    Templates
    Mixins
    Contracts
    Conditional Compilation
    Handling errors
    Garbage Collection
    Memory Management
    Floating Point
    Inline Assembler
    Interfacing To C
    Portability Guide
    Embedding D in HTML
    Named Character Entities
    Application Binary Interface
    +
    +
    +

    Embedding D in HTML

    @@ -76,9 +137,7 @@ Here's an example of the D program "hello world" embedded in this very HTML file. This file can be compiled and run. -

    -
    -
    
    +
     
         import std.c.stdio;
     
    @@ -88,17 +147,17 @@
     	 return 0;
         }
     
    -

    + +

    Feedback and Comments

    - Add Add feedback and comments regarding this - page. + page.

    -
    -Copyright © 1999-2005 by Digital Mars, All Rights Reserved

    +

    -
    diff -uNr dmd-0.129/dmd/html/d/htomodule.html dmd-0.130/dmd/html/d/htomodule.html --- dmd-0.129/dmd/html/d/htomodule.html 2005-05-19 15:08:50.000000000 +0200 +++ dmd-0.130/dmd/html/d/htomodule.html 2005-08-26 11:54:10.000000000 +0200 @@ -12,9 +12,15 @@ - - + + + + + + + + + - + D Programming Language - Converting C .h Files to D Modules + - - + www.digitalmars.com Home | Search | D +| Comments
    -Last update Thu May 19 2005 +Last update Fri Aug 26 2005 +
    + + + +
    +
    +
    + + + + + +
    +D
    +Language
    +Phobos
    +Comparisons +

    + + · Overview
    + · D for Win32
    + · Win32 DLLs in D
    + · C .h to D Modules
    + · FAQ
    + · Style Guide
    + · Example: wc
    + · Future
    + · D Change Log
    + · Tech Tips
    + · Glossary
    + · Acknowledgements
    +
    + Tools +
    + · DMD D Compiler
    + · GDC D Compiler
    + · Linker
    + · Profiler
    +
    + Community +
    + · News Digest
    + · News
    + · Forum
    + · Announcements
    + · Learn
    + · D links
    +
    + Archives +
    + · digitalmars.D
    + · digitalmars.D.dtl
    + · digitalmars.D.announce
    + · digitalmars.D.learn
    + · digitalmars.D.bugs
    + · D.gnu
    + · Old D
    +
    +
    +
    +

    Converting C .h Files to D Modules

    @@ -77,14 +147,12 @@ Generally, surround the entire module with: -

    -
    -
    
    +	
     	extern (C)
     	{
     	     ...file contents...
     	}
    -	

    + to give it C linkage. @@ -152,130 +220,104 @@ as D will implicitly convert strings to wide characters if necessary. However, one can also replace: -

    -
    -
    
    +	
     	L"string"
    -	

    + with: -

    -
    -
    
    +	
     	cast(wchar[])"string"
    -	

    +

    Macros

    Lists of macros like: -

    -
    -
    
    +	
     	#define FOO	1
     	#define BAR	2
     	#define ABC	3
     	#define DEF	40
    -	

    + can be replaced with: -

    -
    -
    
    +	
     	enum
     	{   FOO = 1,
     	    BAR = 2,
     	    ABC = 3,
     	    DEF = 40
     	}
    -	

    + or with: -

    -
    -
    
    +	
     	const int FOO = 1;
     	const int BAR = 2;
     	const int ABC = 3;
     	const int DEF = 40;
    -	

    + Function style macros, such as: -

    -
    -
    
    +	
     	#define MAX(a,b) ((a) < (b) ? (b) : (a))
    -	

    + can be replaced with functions: -

    -
    -
    
    +	
     	int MAX(int a, int b) { return (a < b) ? b : a); }
    -	

    +

    Declaration Lists

    D doesn't allow declaration lists to change the type. Hence: -

    -
    -
    
    +	
     	int *p, q, t[3], *s;
    -	

    + should be written as: -

    -
    -
    
    +	
     	int* p, s;
     	int q;
     	int[3] t;
    -	

    +

    Void Parameter Lists

    Functions that take no parameters: -

    -
    -
    
    +	
     	int foo(void);
    -	

    + are in D: -

    -
    -
    
    +	
     	int foo();
    -	

    +

    Const Type Modifiers

    D has const as a storage class, not a type modifier. Hence, just drop any const used as a type modifier: -

    -
    -
    
    +	
     	void foo(const int *p, char *const q);
    -	

    + becomes: -

    -
    -
    
    +	
     	void foo(int* p, char* q);
    -	

    +

    Extern Global C Variables

    @@ -286,29 +328,23 @@ in that module. For example, given a C header file named foo.h: -

    -
    -
    
    +	
     	struct Foo { };
     	struct Foo bar;
    -	

    + It can be replaced with two D modules, foo.d: -

    -
    -
    
    +	
     	struct Foo { }
     	import fooextern;
    -	

    + and fooextern.d: -

    -
    -
    
    +	
     	Foo bar;
    -	

    + The foo.obj file is linked in, and fooextern.obj is not. While this is not the most elegant looking method, it does @@ -319,44 +355,36 @@ alias is the D equivalent to the C typedef: -

    -
    -
    
    +	
     	typedef int foo;
    -	

    + becomes: -

    -
    -
    
    +	
     	alias int foo;
    -	

    +

    Structs

    Replace declarations like: -

    -
    -
    
    +	
     	typedef struct Foo
     	{   int a;
     	    int b;
     	} Foo, *pFoo, *lpFoo;
    -	

    + with: -

    -
    -
    
    +	
     	struct Foo
     	{   int a;
     	    int b;
     	}
     	alias Foo* pFoo, lpFoo;
    -	

    +

    Struct Member Alignment

    @@ -365,9 +393,7 @@ if the .h file has some #pragma's to control alignment, they can be duplicated with the D align attribute: -

    -
    -
    
    +	
     	#pragma pack(1)
     	struct Foo
     	{
    @@ -375,26 +401,22 @@
     	    int b;
     	};
     	#pragma pack()
    -	

    + becomes: -

    -
    -
    
    +	
     	struct Foo
     	{
     	  align (1):
     	    int a;
     	    int b;
     	}
    -	

    +

    Nested Structs

    -

    -
    -
    
    +	
     	struct Foo
     	{
     	    int a;
    @@ -412,13 +434,11 @@
     		int c;
     	    } bar;
     	};
    -	

    + becomes: -

    -
    -
    
    +	
     	struct Foo
     	{
     	    int a;
    @@ -437,61 +457,51 @@
     		int c;
     	    }
     	};
    -	

    +

    __cdecl, __pascal, __stdcall

    -

    -
    -
    
    +	
     	int __cdecl x;
     	int __cdecl foo(int a);
     	int __pascal bar(int b);
     	int __stdcall abc(int c);
    -	

    + becomes: -

    -
    -
    
    +	
     	extern (C) int x;
     	extern (C) int foo(int a);
     	extern (Pascal) int bar(int b);
     	extern (Windows) int abc(int c);
    -	

    +

    __declspec(dllimport)

    -

    -
    -
    
    +	
     	__declspec(dllimport) int __stdcall foo(int a);
    -	

    + becomes: -

    -
    -
    
    +	
     	export extern (Windows) int foo(int a);
    -	

    +

    __fastcall

    Unfortunately, D doesn't support the __fastcall convention. Therefore, a shim will be needed, either written in C: -

    -
    -
    
    +	
     	int __fastcall foo(int a);
     
     	int myfoo(int a)
     	{
     	    return foo(int a);
     	}
    -	

    + and compiled with a C compiler that supports __fastcall and linked in, or compile the above, disassemble it with @@ -499,15 +509,15 @@ and insert it in a D myfoo shim with inline assembler. +

    Feedback and Comments

    - Add Add feedback and comments regarding this - page. + page.

    -
    -Copyright © 1999-2005 by Digital Mars, All Rights Reserved

    +

    -
    diff -uNr dmd-0.129/dmd/html/d/iasm.html dmd-0.130/dmd/html/d/iasm.html --- dmd-0.129/dmd/html/d/iasm.html 2005-05-19 15:08:50.000000000 +0200 +++ dmd-0.130/dmd/html/d/iasm.html 2005-08-26 11:54:10.000000000 +0200 @@ -12,9 +12,15 @@ - - + + + + + + + + + - + D Programming Language - Inline Assembler + - - + www.digitalmars.com Home | Search | D +| Comments
    -Last update Thu May 19 2005 +Last update Fri Aug 26 2005
    + + + +
    +
    +
    + + + + + +
    +D
    +Language
    +Phobos
    +Comparisons +
    +
    +Lexical
    Modules
    Declarations
    Types
    Properties
    Attributes
    Pragmas
    Expressions
    Statements
    Arrays
    Structs & Unions
    Classes
    Interfaces
    Enums
    Functions
    Operator Overloading
    Templates
    Mixins
    Contracts
    Conditional Compilation
    Handling errors
    Garbage Collection
    Memory Management
    Floating Point
    Inline Assembler
    Interfacing To C
    Portability Guide
    Embedding D in HTML
    Named Character Entities
    Application Binary Interface
    +
    +
    +

    D x86 Inline Assembler

    @@ -1097,15 +1158,15 @@
    +

    Feedback and Comments

    - Add Add feedback and comments regarding this - page. + page.

    -
    -Copyright © 1999-2005 by Digital Mars, All Rights Reserved

    +

    -
    diff -uNr dmd-0.129/dmd/html/d/index.html dmd-0.130/dmd/html/d/index.html --- dmd-0.129/dmd/html/d/index.html 2005-05-21 12:59:28.000000000 +0200 +++ dmd-0.130/dmd/html/d/index.html 2005-08-26 11:54:10.000000000 +0200 @@ -1,32 +1,204 @@ - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + D Programming Language - - - - - - - - <body> - <ul> - <li><a href="toc.html">Table of Contents</a></li> - <li><a href="intro.html">Introduction to D</a></li> - </ul> - </body> - - - - \ Ingen nyrad vid filslut + + + +
    + www.digitalmars.com + + Home + | Search + | D + +
    Last update Thu May 19 2005
    +
    + + + + +
    +
    +
    + + + + + +
    +D
    +Language
    +Phobos
    +Comparisons +
    +
    + + · Overview
    + · D for Win32
    + · Win32 DLLs in D
    + · C .h to D Modules
    + · FAQ
    + · Style Guide
    + · Example: wc
    + · Future
    + · D Change Log
    + · Tech Tips
    + · Glossary
    + · Acknowledgements
    +
    + Tools +
    + · DMD D Compiler
    + · GDC D Compiler
    + · Linker
    + · Profiler
    +
    + Community +
    + · News Digest
    + · News
    + · Forum
    + · Announcements
    + · Learn
    + · D links
    +
    + Archives +
    + · digitalmars.D
    + · digitalmars.D.dtl
    + · digitalmars.D.announce
    + · digitalmars.D.learn
    + · digitalmars.D.bugs
    + · D.gnu
    + · Old D
    +
    +
    +
    + + +

    D Programming Language

    + +
    "It seems to me that most of the "new" programming languages + fall into one of two categories: Those from academia with radical + new paradigms and those from large corporations with a focus on RAD + and the web. Maybe it's time for a new language born out of + practical experience implementing compilers." -- Michael
    + +
    "Great, just what I need.. another D in programming." -- Segfault
    + +

    This is the reference document for the D programming language. + D was conceived in December 1999 by Walter Bright as a reengineering of C and C++, + and has grown and evolved with helpful + suggestions and critiques by friends and colleagues. +

    + +

    Check out the quick comparison + of D with C, C++, C# and Java.

    + +

    The D newsgroup in + news.digitalmars.com + server is where discussions + of this should go. Suggestions, criticism, kudos, flames, etc., + are all welcome there. + Alternatively, try the + D forum. + There also may be a local D user group + in your community (or you can start one!).

    + + +

    Download the current version + of the compiler for Win32 and x86 Linux and try it out.

    + +

    David Friedman has integrated the + D frontend with GCC.

    + + Alternate versions of this document: + + + + "D Language Perfect Guide" + +

    Walter's SDWest 2004 + + presentation on D.

    + +

    Do you feel the + need for speed?

    + +

    Note: all D users agree that by downloading and using + D, or reading the D specs, + they will explicitly identify any claims to intellectual property + rights with a copyright or patent notice in any posted or emailed + feedback sent to Digital Mars.

    + +
    + +

    Feedback and Comments

    + +

    Add feedback and comments regarding this + page.

    + + + + + + + + + + + diff -uNr dmd-0.129/dmd/html/d/interface.html dmd-0.130/dmd/html/d/interface.html --- dmd-0.129/dmd/html/d/interface.html 2005-06-06 18:19:48.000000000 +0200 +++ dmd-0.130/dmd/html/d/interface.html 2005-08-26 11:54:10.000000000 +0200 @@ -12,9 +12,15 @@ - - + + + + + + + + + - + D Programming Language - Interfaces + - - + www.digitalmars.com Home | Search | D +| Comments
    -Last update Mon Jun 06 2005 +Last update Fri Aug 26 2005
    + + + +
    +
    +
    + + + + + +
    +D
    +Language
    +Phobos
    +Comparisons +
    +
    +Lexical
    Modules
    Declarations
    Types
    Properties
    Attributes
    Pragmas
    Expressions
    Statements
    Arrays
    Structs & Unions
    Classes
    Interfaces
    Enums
    Functions
    Operator Overloading
    Templates
    Mixins
    Contracts
    Conditional Compilation
    Handling errors
    Garbage Collection
    Memory Management
    Floating Point
    Inline Assembler
    Interfacing To C
    Portability Guide
    Embedding D in HTML
    Named Character Entities
    Application Binary Interface
    +
    +
    +

    Interfaces

    -

    -
    -
    
    +	
     	InterfaceDeclaration:
     		interface Identifier InterfaceBody
     		interface Identifier : SuperInterfaces InterfaceBody
    @@ -55,7 +114,7 @@
     
     	InterfaceBody:
     		{ DeclDefs }
    -	

    + Interfaces describe a list of functions that a class that inherits from the interface must implement. @@ -67,9 +126,7 @@ Interfaces cannot derive from classes; only from other interfaces. Classes cannot derive from an interface multiple times. -

    -
    -
    
    +	
     	interface D
     	{
     	    void foo();
    @@ -78,14 +135,12 @@
     	class A : D, D	// error, duplicate interface
     	{
     	}
    -	

    + An instance of an interface cannot be created. -

    -
    -
    
    +	
     	interface D
     	{
     	    void foo();
    @@ -94,25 +149,21 @@
     	...
     
     	D d = new D();		// error, cannot create instance of interface
    -	

    + Interface member functions do not have implementations. -

    -
    -
    
    +	
     	interface D
     	{
     	    void bar() { }	// error, implementation not allowed
     	}
    -	

    + All interface functions must be defined in a class that inherits from that interface: -

    -
    -
    
    +	
     	interface D
     	{
     	    void foo();
    @@ -127,13 +178,11 @@
     	{
     	    int foo() { }	// error, no void foo() implementation
     	}
    -	

    + Interfaces can be inherited and functions overridden: -

    -
    -
    
    +	
     	interface D
     	{
     	    int foo();
    @@ -155,13 +204,11 @@
     	b.foo();		// returns 2
     	D d = (D) b;		// ok since B inherits A's D implementation
     	d.foo();		// returns 2;
    -	

    + Interfaces can be reimplemented in derived classes: -

    -
    -
    
    +	
     	interface D
     	{
     	    int foo();
    @@ -186,14 +233,12 @@
     	A a = (A) b;
     	D d2 = (D) a;
     	d2.foo();		// returns 2, even though it is A's D, not B's D
    -	

    + A reimplemented interface must implement all the interface functions, it does not inherit them from a super class: -

    -
    -
    
    +	
     	interface D
     	{
     	    int foo();
    @@ -207,7 +252,7 @@
     	class B : A, D
     	{
     	}		// error, no foo() for interface D
    -	

    +

    COM Interfaces

    @@ -230,15 +275,15 @@ for that interface in standard COM fashion. +

    Feedback and Comments

    - Add Add feedback and comments regarding this - page. + page.

    -
    -Copyright © 1999-2005 by Digital Mars, All Rights Reserved

    +

    -
    diff -uNr dmd-0.129/dmd/html/d/interfaceToC.html dmd-0.130/dmd/html/d/interfaceToC.html --- dmd-0.129/dmd/html/d/interfaceToC.html 2005-06-06 17:59:00.000000000 +0200 +++ dmd-0.130/dmd/html/d/interfaceToC.html 2005-08-26 11:54:10.000000000 +0200 @@ -12,9 +12,15 @@ - - + + + + + + + + + - + D Programming Language - Interfacing to C + - - + www.digitalmars.com Home | Search | D +| Comments
    -Last update Mon Jun 06 2005 +Last update Fri Aug 26 2005
    + + + +
    +
    +
    + + + + + +
    +D
    +Language
    +Phobos
    +Comparisons +
    +
    +Lexical
    Modules
    Declarations
    Types
    Properties
    Attributes
    Pragmas
    Expressions
    Statements
    Arrays
    Structs & Unions
    Classes
    Interfaces
    Enums
    Functions
    Operator Overloading
    Templates
    Mixins
    Contracts
    Conditional Compilation
    Handling errors
    Garbage Collection
    Memory Management
    Floating Point
    Inline Assembler
    Interfacing To C
    Portability Guide
    Embedding D in HTML
    Named Character Entities
    Application Binary Interface
    +
    +
    +

    Interfacing to C

    @@ -63,23 +124,19 @@ The C function must be declared and given a calling convention, most likely the "C" calling convention, for example: -

    -
    -
    
    +	
     	extern (C) int strcmp(char* string1, char* string2);
    -	

    + and then it can be called within D code in the obvious way: -

    -
    -
    
    +	
     	import std.string;
     	int myDfunction(char[] s)
     	{
     	    return strcmp(std.string.toStringz(s), "foo");
     	}
    -	

    + There are several things going on here: @@ -107,9 +164,7 @@ use an attribute that is compatible with the C compiler, most likely the extern (C): -

    -
    -
    
    +	
     	// myfunc() can be called from any C function
     	extern (C)
     	{
    @@ -118,7 +173,7 @@
     		...
     	    }
     	}
    -	

    +

    Storage Allocation

    @@ -358,14 +413,12 @@ dynamic arrays are a length followed by a pointer to the data, the %.*s format works perfectly: -

    -
    -
    
    +	
     	void foo(char[] string)
     	{
     	    printf("my string is: %.*s\n", string);
     	}
    -	

    + The printf format string literal in the example doesn't end with \0. This is because string literals, @@ -400,15 +453,15 @@ D class objects are incompatible with C++ class objects. +

    Feedback and Comments

    - Add Add feedback and comments regarding this - page. + page.

    -
    -Copyright © 1999-2005 by Digital Mars, All Rights Reserved

    +

    -
    diff -uNr dmd-0.129/dmd/html/d/intro.html dmd-0.130/dmd/html/d/intro.html --- dmd-0.129/dmd/html/d/intro.html 2005-07-30 11:51:48.000000000 +0200 +++ dmd-0.130/dmd/html/d/intro.html 2005-08-26 11:54:10.000000000 +0200 @@ -1,3 +1,23 @@ + + + + + + + + + + + + + + + + + + + + @@ -26,6 +46,69 @@
    Last update Thu May 19 2005
    + + + +
    +
    +
    + + + + + +
    +D
    +Language
    +Phobos
    +Comparisons +
    +
    + + · Overview
    + · D for Win32
    + · Win32 DLLs in D
    + · C .h to D Modules
    + · FAQ
    + · Style Guide
    + · Example: wc
    + · Future
    + · D Change Log
    + · Tech Tips
    + · Glossary
    + · Acknowledgements
    +
    + Tools +
    + · DMD D Compiler
    + · GDC D Compiler
    + · Linker
    + · Profiler
    +
    + Community +
    + · News Digest
    + · News
    + · Forum
    + · Announcements
    + · Learn
    + · D links
    +
    + Archives +
    + · digitalmars.D
    + · digitalmars.D.dtl
    + · digitalmars.D.announce
    + · digitalmars.D.learn
    + · digitalmars.D.bugs
    + · D.gnu
    + · Old D
    +
    +
    +
    + +

    D Programming Language

    "It seems to me that most of the "new" programming languages @@ -91,28 +174,31 @@ rights with a copyright or patent notice in any posted or emailed feedback sent to Digital Mars.

    +
    -

    Feedback and Comments

    +

    Feedback and Comments

    Add feedback and comments regarding this page.

    - + + - - - + + + + diff -uNr dmd-0.129/dmd/html/d/lex.html dmd-0.130/dmd/html/d/lex.html --- dmd-0.129/dmd/html/d/lex.html 2005-07-19 10:11:16.000000000 +0200 +++ dmd-0.130/dmd/html/d/lex.html 2005-08-26 11:54:10.000000000 +0200 @@ -12,9 +12,15 @@ - - + + + + + + + + + - + D Programming Language - Lexical + - - + www.digitalmars.com Home | Search | D +| Comments
    -Last update Tue Jul 19 2005 +Last update Fri Aug 26 2005
    + + + +
    +
    +
    + + + + + +
    +D
    +Language
    +Phobos
    +Comparisons +
    +
    +Lexical
    Modules
    Declarations
    Types
    Properties
    Attributes
    Pragmas
    Expressions
    Statements
    Arrays
    Structs & Unions
    Classes
    Interfaces
    Enums
    Functions
    Operator Overloading
    Templates
    Mixins
    Contracts
    Conditional Compilation
    Handling errors
    Garbage Collection
    Memory Management
    Floating Point
    Inline Assembler
    Interfacing To C
    Portability Guide
    Embedding D in HTML
    Named Character Entities
    Application Binary Interface
    +
    +
    +

    Lexical

    @@ -161,37 +222,31 @@

    End of File

    -

    -
    -
    
    +	
     	EndOfFile:
     		physical end of the file
     		\u0000
     		\u001A
    -	

    + The source text is terminated by whichever comes first.

    End of Line

    -

    -
    -
    
    +	
     	EndOfLine:
     		\u000D
     		\u000A
     		\u000D \u000A
     		EndOfFile
    -	

    + There is no backslash line splicing, nor are there any limits on the length of a line.

    White Space

    -

    -
    -
    
    +	
     	WhiteSpace:
     		Space
     		Space WhiteSpace
    @@ -203,21 +258,19 @@
     		\u000C
     		EndOfLine
     		Comment
    -	

    + White space is defined as a sequence of one or more of spaces, tabs, vertical tabs, form feeds, end of lines, or comments.

    Comments

    -

    -
    -
    
    +	
     	Comment:
     		/* Characters */
     		// Characters EndOfLine
     		/+ Characters +/
    -	

    + D has three kinds of comments:

      @@ -243,9 +296,7 @@

      Tokens

      -

      -
      -
      
      +	
       	Token:
       		Identifier
       		StringLiteral
      @@ -313,13 +364,11 @@
       		^=
       		~
       		~=
      -	

      +

      Identifiers

      -

      -
      -
      
      +	
       	Identifier:
       		IdentiferStart
       		IdentiferStart IdentifierChars
      @@ -336,7 +385,7 @@
       	IdentifierChar:
       		IdentiferStart
       		Digit
      -	

      + Identifiers start with a letter, _, or universal alpha, @@ -349,9 +398,7 @@

      String Literals

      -

      -
      -
      
      +	
       	StringLiteral:
       		WysiwygString
       		AlternateWysiwygString
      @@ -410,7 +457,7 @@
       		c
       		w
       		d
      -	

      + A string literal is either a double quoted string, a wysiwyg quoted string, an escape sequence, or a hex string. @@ -486,7 +533,8 @@ juxtaposition:

      -	"hello " ~ "world" ~ \n	// forms the string 'h','e','l','l','o',' ','w','o','r','l','d',linefeed
      +	"hello " ~ "world" ~ \n	// forms the string 'h','e','l','l','o',' ',
      +				// 'w','o','r','l','d',linefeed
       	
      The following are all equivalent: @@ -523,25 +571,21 @@

      Character Literals

      -

      -
      -
      
      +	
       	CharacterLiteral:
       		' SingleQuotedCharacter '
       
       	SingleQuotedCharacter
       		Character
       		EscapeSequence
      -	

      + Character literals are a single character or escape sequence enclosed by single quotes, ' '.

      Integer Literals

      -

      -
      -
      
      +	
       	IntegerLiteral:
       		Integer
       		Integer IntegerSuffix
      @@ -583,7 +627,7 @@
       	Hexadecimal:
       		0x HexDigits
       		0X HexDigits
      -	

      + Integers can be specified in decimal, binary, octal, or hexadecimal.

      @@ -687,9 +731,7 @@

      Floating Literals

      -

      -
      -
      
      +	
       	FloatLiteral:
       		Float
       		Float FloatSuffix
      @@ -710,7 +752,7 @@
       	ImaginarySuffix:
       		i
       		I
      -	

      + Floats can be in decimal or hexadecimal format, as in standard C. @@ -770,9 +812,7 @@ Keywords are reserved identifiers. -

      -
      -
      
      +	
       	Keyword:
       		abstract
       		alias
      @@ -885,7 +925,7 @@
       		wchar
       		while
       		with
      -	

      +

      Special Tokens

      @@ -924,16 +964,14 @@ There is currently only one special token sequence, #line. -

      -
      -
      
      +	
       	SpecialTokenSequence
       		# line Integer EndOfLine
       		# line Integer Filespec EndOfLine
       
       	Filespec
       		" Characters "
      -	

      + This sets the source line number to Integer, and optionally the source file name to Filespec, @@ -945,25 +983,23 @@ For example: -

      -
      -
      
      +	
       	int #line 6 "foo\bar"
       	x;			// this is now line 6 of file foo\bar
      -	

      + Note that the backslash character is not treated specially inside Filespec strings. +

    Feedback and Comments

    - Add Add feedback and comments regarding this - page. + page.

    -
    -Copyright © 1999-2005 by Digital Mars, All Rights Reserved

    +

    -
    diff -uNr dmd-0.129/dmd/html/d/memory.html dmd-0.130/dmd/html/d/memory.html --- dmd-0.129/dmd/html/d/memory.html 2005-06-01 15:01:32.000000000 +0200 +++ dmd-0.130/dmd/html/d/memory.html 2005-08-28 21:46:34.000000000 +0200 @@ -12,9 +12,15 @@ - - + + + + + + + + + - + D Programming Language - Memory Management + - - + www.digitalmars.com Home | Search | D +| Comments
    -Last update Wed Jun 01 2005 +Last update Sun Aug 28 2005
    + + + +
    +
    +
    + + + + + +
    +D
    +Language
    +Phobos
    +Comparisons +
    +
    +Lexical
    Modules
    Declarations
    Types
    Properties
    Attributes
    Pragmas
    Expressions
    Statements
    Arrays
    Structs & Unions
    Classes
    Interfaces
    Enums
    Functions
    Operator Overloading
    Templates
    Mixins
    Contracts
    Conditional Compilation
    Handling errors
    Garbage Collection
    Memory Management
    Floating Point
    Inline Assembler
    Interfacing To C
    Portability Guide
    Embedding D in HTML
    Named Character Entities
    Application Binary Interface
    +
    +
    +

    Memory Management

    @@ -84,9 +145,7 @@ For example, a function to convert an array of characters to upper case: -

    -
    -
    
    +
     	char[] toupper(char[] s)
     	{
     	    int i;
    @@ -99,7 +158,7 @@
     	    }
     	    return s;
     	}
    -

    + Note that the caller's version of s[] is also modified. This may be not at all what was intended, or worse, s[] may be a slice @@ -119,9 +178,7 @@ it'll have to be done explicitly in the code. Here's toupper() rewritten to implement copy-on-write in an efficient manner: -

    -
    -
    
    +
     	char[] toupper(char[] s)
     	{
     	    int changed;
    @@ -144,7 +201,7 @@
     	    }
     	    return s;
     	}
    -

    + Copy-on-write is the protocol implemented by array processing functions in the D Phobos runtime library. @@ -193,9 +250,7 @@ deallocating an object when done with it, put it on a free list. When allocating, pull one off the free list first. -

    -
    -
    
    +
     	class Foo
     	{
     	    static Foo freelist;		// start of free list
    @@ -228,7 +283,7 @@
     	    ...
     	    Foo.deallocate(f);
     	}
    -

    + Such free list approaches can be very high performance. @@ -272,9 +327,7 @@ For example, to allocate using the C runtime library's malloc and free: -

    -
    -
    
    +
     	import std.c.stdlib;
     	import std.outofmemory;
     	import std.gc;
    @@ -300,7 +353,7 @@
     		}
     	    }
     	}
    -

    + The critical features of new() are: @@ -366,9 +419,7 @@ 'marked', and then whole sections of memory are released simply by resetting the stack pointer back to a marked point. -

    -
    -
    
    +
     	import std.c.stdlib;
     	import std.outofmemory;
     
    @@ -432,7 +483,7 @@
     	    ...
     	    Foo.release(m);		// deallocate f1 and f2
     	}
    -

    +

  • The allocation of buffer[] itself is added as a region to the gc, so there is no need for a separate @@ -461,9 +512,7 @@ Although the current implementation does not put such objects on the stack, future ones can. -

    -
    -
    
    +
     	import std.c.stdlib;
     
     	class Foo
    @@ -484,7 +533,7 @@
     	    Foo f = new(std.c.stdlib.alloca(Foo.classinfo.init.length)) Foo;
     	    ...
     	}
    -

    +

    • There is no need to check for a failure of alloca() and @@ -502,32 +551,28 @@ Arrays are always initialized in D. So, the following declaration: -

      -
      -
      
      +	
       	void foo()
       	{   byte[1024] buffer;
       
       	    fillBuffer(buffer);
       	    ...
       	}
      -	

      + will not be as fast as it might be since the buffer[] contents are always initialized. If careful profiling of the program shows that this initialization is a speed problem, it can be eliminated using a VoidInitializer: -

      -
      -
      
      +	
       	void foo()
       	{   byte[1024] buffer = void;
       
       	    fillBuffer(buffer);
       	    ...
       	}
      -	

      + Uninitialized data on the stack comes with some caveats that need to be carefully evaluated before using: @@ -558,15 +603,15 @@

    +
  • Feedback and Comments

    - Add Add feedback and comments regarding this - page. + page.

    -
    -Copyright © 1999-2005 by Digital Mars, All Rights Reserved

    +

    -
    diff -uNr dmd-0.129/dmd/html/d/mixin.html dmd-0.130/dmd/html/d/mixin.html --- dmd-0.129/dmd/html/d/mixin.html 2005-05-19 15:08:50.000000000 +0200 +++ dmd-0.130/dmd/html/d/mixin.html 2005-08-26 11:54:10.000000000 +0200 @@ -12,9 +12,15 @@ - - + + + + + + + + + - + D Programming Language - Mixins + - - + www.digitalmars.com Home | Search | D +| Comments
    -Last update Thu May 19 2005 +Last update Fri Aug 26 2005 +
    + + + +
    +
    +
    + + + + + +
    +D
    +Language
    +Phobos
    +Comparisons +

    +Lexical
    Modules
    Declarations
    Types
    Properties
    Attributes
    Pragmas
    Expressions
    Statements
    Arrays
    Structs & Unions
    Classes
    Interfaces
    Enums
    Functions
    Operator Overloading
    Templates
    Mixins
    Contracts
    Conditional Compilation
    Handling errors
    Garbage Collection
    Memory Management
    Floating Point
    Inline Assembler
    Interfacing To C
    Portability Guide
    Embedding D in HTML
    Named Character Entities
    Application Binary Interface
    +
    +
    +

    Mixins

    @@ -75,9 +136,7 @@ templated nested functions, which is not possible with template instantiations. -

    -
    -
    
    +	
     	template Foo()
     	{
     	    int x = 5;
    @@ -108,26 +167,22 @@
     	    }
     	    printf("x = %d\n", x);		// prints 5
     	}
    -	

    + Mixins can be parameterized: -

    -
    -
    
    +	
     	template Foo(T)
     	{
     	    T x = 5;
     	}
     
     	mixin Foo!(int);		// create x of type int
    -	

    + Mixins can add virtual functions to a class: -

    -
    -
    
    +	
     	template Foo()
     	{
     	    void func() { printf("Foo.func()\n"); }
    @@ -151,14 +206,12 @@
     	    b = new Code();
     	    b.func();		// calls Code.func()
     	}
    -	

    + Mixins are evaluted in the scope of where they appear, not the scope of the template declaration: -

    -
    -
    
    +	
     	int y = 3;
     
     	template Foo()
    @@ -172,13 +225,11 @@
     	    mixin Foo;	// local y is picked up, not global y
     	    assert(abc() == 8);
     	}
    -	

    + Mixins can parameterize symbols using alias parameters: -

    -
    -
    
    +	
     	template Foo(alias b)
     	{
     	    int abc() { return b; }
    @@ -190,16 +241,14 @@
     	    mixin Foo!(y);
     	    assert(abc() == 8);
     	}
    -	

    + This example uses a mixin to implement a generic Duff's device for an arbitrary statement (in this case, the arbitrary statement is in bold). A nested function is generated as well as a delegate literal, these can be inlined by the compiler: -

    -
    -
    
    +	
     	template duffs_device(alias id1, alias id2, alias s)
     	{
     	    void duff_loop()
    @@ -233,7 +282,7 @@
     	    mixin duffs_device!(i, j, delegate { foo(); } );
     	    duff_loop();	// executes foo() 10 times
     	}
    -	

    +

    Mixin Scope

    @@ -242,9 +291,7 @@ as a declaration in the surrounding scope, the surrounding declaration overrides the mixin one: -

    -
    -
    
    +	
     	int x = 3;
     
     	template Foo()
    @@ -261,15 +308,13 @@
     	    printf("x = %d\n", x);	// prints 3
     	    printf("y = %d\n", y);	// prints 3
     	}
    -	

    + If two different mixins are put in the same scope, and each define a declaration with the same name, there is an ambiguity error when the declaration is referenced: -

    -
    -
    
    +	
     	template Foo()
     	{
     	    int x = 5;
    @@ -287,14 +332,12 @@
     	{
     	    printf("x = %d\n", x);	// error, x is ambiguous
     	}
    -	

    + If a mixin has a MixinIdentifier, it can be used to disambiguate: -

    -
    -
    
    +	
     	int x = 6;
     
     	template Foo()
    @@ -318,14 +361,12 @@
     	    printf("F.x = %d\n", F.x);	// prints 5
     	    printf("B.x = %d\n", B.x);	// prints 4
     	}
    -	

    + A mixin has its own scope, even if a declaration is overridden by the enclosing one: -

    -
    -
    
    +	
     	int x = 4;
     
     	template Foo()
    @@ -341,17 +382,17 @@
     	    printf("x = %d\n", x);		// prints 4
     	    printf("bar() = %d\n", bar());	// prints 5
     	}
    -	

    + +

    Feedback and Comments

    - Add Add feedback and comments regarding this - page. + page.

    -
    -Copyright © 1999-2005 by Digital Mars, All Rights Reserved

    +

    -
    diff -uNr dmd-0.129/dmd/html/d/module.html dmd-0.130/dmd/html/d/module.html --- dmd-0.129/dmd/html/d/module.html 2005-05-19 15:08:50.000000000 +0200 +++ dmd-0.130/dmd/html/d/module.html 2005-08-28 21:46:34.000000000 +0200 @@ -12,9 +12,15 @@ - - + + + + + + + + + - + D Programming Language - Modules + - - + www.digitalmars.com Home | Search | D +| Comments
    -Last update Thu May 19 2005 +Last update Sun Aug 28 2005
    + + + +
    +
    +
    + + + + + +
    +D
    +Language
    +Phobos
    +Comparisons +
    +
    +Lexical
    Modules
    Declarations
    Types
    Properties
    Attributes
    Pragmas
    Expressions
    Statements
    Arrays
    Structs & Unions
    Classes
    Interfaces
    Enums
    Functions
    Operator Overloading
    Templates
    Mixins
    Contracts
    Conditional Compilation
    Handling errors
    Garbage Collection
    Memory Management
    Floating Point
    Inline Assembler
    Interfacing To C
    Portability Guide
    Embedding D in HTML
    Named Character Entities
    Application Binary Interface
    +
    +
    +

    Modules

    -

    -
    -
    
    +	
     	Module:
     		ModuleDeclaration DeclDefs
     		DeclDefs
    @@ -70,7 +129,7 @@
     		DebugSpecification
     		VersionSpecification
     		;
    -	

    + Modules have a one-to-one correspondence with source files. @@ -97,7 +156,7 @@ by surrounding attributes or other modifiers. - Modules can be grouped together in heirarchies called packages. + Modules can be grouped together in hierarchies called packages.

    Module Declaration

    @@ -105,16 +164,14 @@ package it belongs to. If absent, the module name is taken to be the same name (stripped of path and extension) of the source file name. -

    -
    -
    
    +	
     	ModuleDeclaration:
     		module ModuleName ;
     
     	ModuleName:
     		Identifier
     		ModuleName . Identifier
    -	

    + The Identifier preceding the rightmost are the packages that the module is in. The packages correspond to directory names in @@ -127,11 +184,9 @@ Example: -

    -
    -
    
    +	
     	module c.stdio;    // this is module stdio in the c package
    -	

    + By convention, package and module names are all lower case. This is because those names have a one-to-one correspondence with the operating @@ -144,16 +199,14 @@ Rather than text include files, D imports symbols symbolically with the import declaration: -

    -
    -
    
    +	
     	ImportDeclaration:
     		import ModuleNameList ;
     
     	ModuleNameList:
     		ModuleName
     		ModuleName , ModuleNameList
    -	

    + The rightmost Identifier becomes the module name. The top level scope in the module is merged with the current scope. @@ -161,12 +214,10 @@ Example: -

    -
    -
    
    +	
     	import std.c.stdio;  // import module stdio from the c package
     	import foo, bar;     // import modules foo and bar
    -	

    +

    Scope and Modules

    @@ -179,9 +230,7 @@ For example, assume the following modules: -

    -
    -
    
    +	
     	Module foo
     	int x = 1;
     	int y = 2;
    @@ -189,56 +238,46 @@
     	Module bar
     	int y = 3;
     	int z = 4;
    -	

    + then: -

    -
    -
    
    +	
     	import foo;
     	...
     	q = y;		// sets q to foo.y
    -	

    + and: -

    -
    -
    
    +	
     	import foo;
     	int y = 5;
     	q = y;		// local y overrides foo.y
    -	

    + and: -

    -
    -
    
    +	
     	import foo;
     	import bar;
     	q = y;		// error: foo.y or bar.y?
    -	

    + and: -

    -
    -
    
    +	
     	import foo;
     	import bar;
     	q = bar.y;	// q set to 3
    -	

    + If the import is private, such as: -

    -
    -
    
    +	
     	module abc;
     	private import def;
    -	

    + then def is not searched when another module imports abc. @@ -248,9 +287,7 @@ to access a name hidden by a local name. This is done with the global scope operator, which is a leading '.': -

    -
    -
    
    +	
     	int x;
     
     	int foo(int x)
    @@ -260,7 +297,7 @@
     	    else
     		return .x;		// returns global x
     	}
    -	

    + The leading '.' means look up the name at the module scope level. @@ -304,15 +341,15 @@ Unit tests are run in the lexical order in which they appear within a module. +

    Feedback and Comments

    - Add Add feedback and comments regarding this - page. + page.

    -
    -Copyright © 1999-2005 by Digital Mars, All Rights Reserved

    +

    -
    diff -uNr dmd-0.129/dmd/html/d/operatoroverloading.html dmd-0.130/dmd/html/d/operatoroverloading.html --- dmd-0.129/dmd/html/d/operatoroverloading.html 2005-05-19 15:08:50.000000000 +0200 +++ dmd-0.130/dmd/html/d/operatoroverloading.html 2005-08-26 11:54:10.000000000 +0200 @@ -12,9 +12,15 @@ - - + + + + + + + + + - + D Programming Language - Operator Overloading + - - + www.digitalmars.com Home | Search | D +| Comments
    -Last update Thu May 19 2005 +Last update Fri Aug 26 2005
    + + + +
    +
    +
    + + + + + +
    +D
    +Language
    +Phobos
    +Comparisons +
    +
    +Lexical
    Modules
    Declarations
    Types
    Properties
    Attributes
    Pragmas
    Expressions
    Statements
    Arrays
    Structs & Unions
    Classes
    Interfaces
    Enums
    Functions
    Operator Overloading
    Templates
    Mixins
    Contracts
    Conditional Compilation
    Handling errors
    Garbage Collection
    Memory Management
    Floating Point
    Inline Assembler
    Interfacing To C
    Portability Guide
    Embedding D in HTML
    Named Character Entities
    Application Binary Interface
    +
    +
    +

    Operator Overloading

    @@ -591,15 +652,15 @@ be overloadable. The names of the overloaded operators may change. +

    Feedback and Comments

    - Add Add feedback and comments regarding this - page. + page.

    -
    -Copyright © 1999-2005 by Digital Mars, All Rights Reserved

    +

    -
    diff -uNr dmd-0.129/dmd/html/d/overview.html dmd-0.130/dmd/html/d/overview.html --- dmd-0.129/dmd/html/d/overview.html 2005-06-09 02:17:28.000000000 +0200 +++ dmd-0.130/dmd/html/d/overview.html 2005-08-28 21:46:34.000000000 +0200 @@ -12,9 +12,15 @@ - - + + + + + + + + + - + Digital Mars - The D Programming Language + - - + www.digitalmars.com Home | Search | D +| Comments
    -Last update Thu Jun 09 2005 +Last update Sun Aug 28 2005
    + + + +
    +
    +
    + + + + + +
    +D
    +Language
    +Phobos
    +Comparisons +
    +
    + + · Overview
    + · D for Win32
    + · Win32 DLLs in D
    + · C .h to D Modules
    + · FAQ
    + · Style Guide
    + · Example: wc
    + · Future
    + · D Change Log
    + · Tech Tips
    + · Glossary
    + · Acknowledgements
    +
    + Tools +
    + · DMD D Compiler
    + · GDC D Compiler
    + · Linker
    + · Profiler
    +
    + Community +
    + · News Digest
    + · News
    + · Forum
    + · Announcements
    + · Learn
    + · D links
    +
    + Archives +
    + · digitalmars.D
    + · digitalmars.D.dtl
    + · digitalmars.D.announce
    + · digitalmars.D.learn
    + · digitalmars.D.bugs
    + · D.gnu
    + · Old D
    +
    +
    +
    +

    Overview

    @@ -477,7 +547,7 @@
     	class Foo
     	{
    -	    int foo(Bar *c) { return c->bar; }
    +	    int foo(Bar *c) { return c->bar(); }
     	};
     
     	class Bar
    @@ -903,9 +973,7 @@
     

    Sample D Program (sieve.d)

    -

    -
    -
    
    +
     /* Sieve of Eratosthenes prime numbers */
      
     bit[8191] flags;
    @@ -933,17 +1001,17 @@
         printf ("\n%d primes", count);
         return 0;
     }
    -

    +

    +

    Feedback and Comments

    - Add Add feedback and comments regarding this - page. + page.

    -
    -Copyright © 1999-2005 by Digital Mars, All Rights Reserved

    +

    -
    diff -uNr dmd-0.129/dmd/html/d/phobos/object.html dmd-0.130/dmd/html/d/phobos/object.html --- dmd-0.129/dmd/html/d/phobos/object.html 1970-01-01 01:00:00.000000000 +0100 +++ dmd-0.130/dmd/html/d/phobos/object.html 2005-08-22 22:42:58.000000000 +0200 @@ -0,0 +1,239 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Digital Mars - The D Programming Language - object + + + + +www.digitalmars.com + +Home +| Search +| D +| Comments + +
    +Last update Mon Aug 22 2005 +
    + + + +
    +
    +
    + + + + + +
    +
    +
    D
    +
    Language
    +
    Phobos
    +
    Comparisons


    + +object
    +
    + +std
    std.base64
    std.boxer
    std.compiler
    std.conv
    std.ctype
    std.date
    std.file
    std.format
    std.gc
    std.intrinsic
    std.math
    std.md5
    std.mmfile
    std.openrj
    std.outbuffer
    std.path
    std.process
    std.random
    std.recls
    std.regexp
    std.socket
    std.socketstream
    std.stdint
    std.stdio
    std.cstream
    std.stream
    std.string
    std.system
    std.thread
    std.uri
    std.utf
    std.zip
    std.zlib
    +
    +std.windows
    +
    +std.linux
    +
    +std.c
    std.c.stdio
    +
    +std.c.windows
    +
    +std.c.linux
    +
    +
    +
    + + +

    object

    + +This module is implicitly imported. + +
    + +
    alias size_t +
    An unsigned integral type large enough to span the memory + space. Use for array indices and pointer offsets for maximal portability + to architectures that have different memory address ranges. + This is analogous to C's size_t. +

    + +

    alias ptrdiff_t +
    A signed integral type large enough to span the memory + space. Use for pointer differences and for size_t + differences for maximal portability + to architectures that have different memory address ranges. + This is analogous to C's ptrdiff_t. +

    + +

    int printf(char* format, ...); +
    C's printf function. +

    + +

    class Object +
    All class objects in D inherit from Object. +

    +

    +
    char[] toString() +
    Convert Object to a human readable string. +

    + +

    uint toHash() +
    Compute hash function for Object. +

    + +

    int opCmp(Object obj) +
    Compare with another Object obj. Returns: +
    +
    <0 for (this < obj) +
    =0 for (this == obj) +
    >0 for (this > obj) +
    +

    + +

    int opEquals(Object obj) +
    Returns !=0 if this object does have the same + contents as obj. +

    +

    + +
    class ClassInfo +
    Runtime type information about a class. + Can be retrieved for any class type or instance by using + the .classinfo property. +

    + +

    class TypeInfo +
    Runtime type information about a type. + Can be retrieved for any type using a + TypeidExpression. +

    + +

    class Exception +
    All recoverable exceptions should be derived from class + Exception. +

    +

    +
    this(char[] msg) +
    Constructor; msg is a descriptive message + for the exception. +
    +

    + +

    class Error +
    All irrecoverable exceptions should be derived from class + Error. +

    +

    +
    this(char[] msg) +
    Constructor; msg is a descriptive message + for the error. +
    +

    + +

    + + +
    +

    Feedback and Comments

    + + Add feedback and comments regarding this + page. + +
    +Copyright © 1999-2005 by Digital Mars, All Rights Reserved

    + + + + + + + + + + diff -uNr dmd-0.129/dmd/html/d/phobos/phobos.html dmd-0.130/dmd/html/d/phobos/phobos.html --- dmd-0.129/dmd/html/d/phobos/phobos.html 1970-01-01 01:00:00.000000000 +0100 +++ dmd-0.130/dmd/html/d/phobos/phobos.html 2005-08-22 22:42:58.000000000 +0200 @@ -0,0 +1,429 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +D Programming Language - Phobos Runtime Library + + + + +www.digitalmars.com + +Home +| Search +| D +| Comments + +
    +Last update Mon Aug 22 2005 +


    + + + +
    +
    +
    + + + + + +
    +
    +
    D
    +
    Language
    +
    Phobos
    +
    Comparisons


    + +object
    +
    + +std
    std.base64
    std.boxer
    std.compiler
    std.conv
    std.ctype
    std.date
    std.file
    std.format
    std.gc
    std.intrinsic
    std.math
    std.md5
    std.mmfile
    std.openrj
    std.outbuffer
    std.path
    std.process
    std.random
    std.recls
    std.regexp
    std.socket
    std.socketstream
    std.stdint
    std.stdio
    std.cstream
    std.stream
    std.string
    std.system
    std.thread
    std.uri
    std.utf
    std.zip
    std.zlib
    +
    +std.windows
    +
    +std.linux
    +
    +std.c
    std.c.stdio
    +
    +std.c.windows
    +
    +std.c.linux
    +
    +
    +
    + + +

    Phobos

    D Runtime Library

    + +Phobos is the standard runtime library that comes with the +D language compiler. Also, check out the +wiki for Phobos. + + +

    Philosophy

    + + Each module in Phobos conforms as much as possible to the + following design goals. These are goals + rather than requirements because D is not a religion, + it's a programming language, and it recognizes that + sometimes the goals are contradictory and counterproductive + in certain situations, and programmers have + jobs that need to get done. + +
    + + +
    Machine and Operating System Independent Interfaces + +
    It's pretty well accepted that gratuitous non-portability + should be avoided. This should not be + construed, however, as meaning that access to unusual + features of an operating system should be prevented. + + +
    Simple Operations should be Simple + +
    A common and simple operation, like writing an array of + bytes to a file, should be simple to + code. I haven't seen a class library yet that simply and efficiently + implemented common, basic file I/O operations. + + +
    Classes should strive to be independent of one another + +
    It's discouraging to pull in a megabyte of code bloat + by just trying to read a file into an array of + bytes. Class independence also means that classes that turn + out to be mistakes can be deprecated and redesigned without + forcing a rewrite of the rest of the class library. + + +
    No pointless wrappers around C runtime library functions or OS API functions + +
    D provides direct access to C runtime library functions + and operating system API functions. + Pointless D wrappers around those functions just adds blather, + bloat, baggage and bugs. + + +
    Class implementations should use DBC + +
    This will prove that DBC (Contract Programming) is worthwhile. + Not only will it aid in debugging the class, but + it will help every class user use the class correctly. + DBC in the class library will have great leverage. + + +
    Use Exceptions for Error Handling + +
    See Error Handling in D. + +
    + +
    +

    Imports

    + + Runtime library modules can be imported with the + import statement. Each module falls into one of several + packages: + +
    +
    std +
    These are the core modules. +

    + +

    +
    std.windows +
    Modules specific to the Windows operating system. +

    + +

    std.linux +
    Modules specific to the Linux operating system. +

    + +

    std.c +
    Modules that are simply interfaces to C functions. + For example, interfaces to standard C library functions + will be in std.c, such as std.c.stdio would be the interface + to C's stdio.h. +

    + +

    +
    std.c.windows +
    Modules corresponding to the C Windows API functions. +

    + +

    std.c.linux +
    Modules corresponding to the C Linux API functions. +

    + +

    +
    + +
    + +
    +
    etc +
    This is the root of a hierarchy of modules mirroring the std + hierarchy. Modules in etc are not standard D modules. They are + here because they are experimental, or for some other reason are + not quite suitable for std, although they are still useful. +

    +

    + +
    +

    std: Core library modules

    + +
    + +
    std.base64 +
    Encode/decode base64 format. + +
    std.boxer +
    Box/unbox types. + +
    std.compiler +
    Information about the D compiler implementation. + +
    std.conv +
    Conversion of strings to integers. + +
    std.ctype +
    Simple character classification + +
    std.date +
    Date and time functions. Support locales. + +
    std.file +
    Basic file operations like read, write, append. + +
    std.format +
    Formatted conversions of values to strings. + +
    std.gc +
    Control the garbage collector. + +
    std.intrinsic +
    Compiler built in intrinsic functions + +
    std.math +
    Include all the usual math functions like sin, cos, atan, etc. + +
    std.md5 +
    Compute MD5 digests. + +
    std.mmfile +
    Memory mapped files. + +
    object +
    The root class of the inheritance hierarchy + +
    std.openrj +
    Basic database. + +
    std.outbuffer +
    Assemble data into an array of bytes + +
    std.path +
    Manipulate file names, path names, etc. + +
    std.process +
    Create/destroy threads. + +
    std.random +
    Random number generation. + +
    std.recls +
    Recursively search file system and (currently Windows + only) FTP sites. + +
    std.regexp +
    The usual regular expression functions. + +
    std.socket +
    Sockets. + +
    std.socketstream +
    Stream for a blocking, connected Socket. + +
    std.stdint +
    Integral types for various purposes. + +
    std.stdio +
    Standard I/O. + +
    std.cstream +
    Stream I/O. + +
    std.stream +
    Stream I/O. + +
    std.string +
    Basic string operations not covered by array ops. + +
    std.system +
    Inquire about the CPU, operating system. + +
    std.thread +
    One per thread. Operations to do on a thread. + +
    std.uri +
    Encode and decode Uniform Resource Identifiers (URIs). + +
    std.utf +
    Encode and decode utf character encodings. + +
    std.zip +
    Read/write zip archives. + +
    std.zlib +
    Compression / Decompression of data. + +
    + +
    +

    std.windows: Modules specific to the Windows operating system

    + +
    + +
    std.windows.syserror +
    Convert Windows error codes to strings. + +
    + +
    +

    std.linux: Modules specific to the Linux operating system

    + +
    +

    std.c: Interface to C functions

    + +
    + +
    std.c.stdio +
    Interface to C stdio functions like printf(). + +
    + +
    +

    std.c.windows: Interface to C Windows functions

    + +
    + +
    std.c.windows.windows +
    Interface to Windows APIs + +
    + +
    +

    std.c.linux: Interface to C Linux functions

    + +
    + +
    std.c.linux.linux +
    Interface to Linux APIs + +
    + +
    +

    std.c.stdio

    + +
    +
    int printf(char* format, ...) +
    C printf() function. +
    + +
    +

    Feedback and Comments

    + + Add feedback and comments regarding this + page. + +
    +Copyright © 1999-2005 by Digital Mars, All Rights Reserved

    + + + + + + + + + + diff -uNr dmd-0.129/dmd/html/d/phobos/std_base64.html dmd-0.130/dmd/html/d/phobos/std_base64.html --- dmd-0.129/dmd/html/d/phobos/std_base64.html 1970-01-01 01:00:00.000000000 +0100 +++ dmd-0.130/dmd/html/d/phobos/std_base64.html 2005-08-22 22:42:58.000000000 +0200 @@ -0,0 +1,158 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Digital Mars - The D Programming Language - std.base64 + + + + +www.digitalmars.com + +Home +| Search +| D +| Comments + +
    +Last update Mon Aug 22 2005 +


    + + + +
    +
    +
    + + + + + +
    +
    +
    D
    +
    Language
    +
    Phobos
    +
    Comparisons


    + +object
    +
    + +std
    std.base64
    std.boxer
    std.compiler
    std.conv
    std.ctype
    std.date
    std.file
    std.format
    std.gc
    std.intrinsic
    std.math
    std.md5
    std.mmfile
    std.openrj
    std.outbuffer
    std.path
    std.process
    std.random
    std.recls
    std.regexp
    std.socket
    std.socketstream
    std.stdint
    std.stdio
    std.cstream
    std.stream
    std.string
    std.system
    std.thread
    std.uri
    std.utf
    std.zip
    std.zlib
    +
    +std.windows
    +
    +std.linux
    +
    +std.c
    std.c.stdio
    +
    +std.c.windows
    +
    +std.c.linux
    +
    +
    +
    + + +

    std.base64

    + + +Encodes/decodes base64 data. + + +
    +

    Feedback and Comments

    + + Add feedback and comments regarding this + page. + +
    +Copyright © 1999-2005 by Digital Mars, All Rights Reserved

    + + + + + + + + + + + + diff -uNr dmd-0.129/dmd/html/d/phobos/std_boxer.html dmd-0.130/dmd/html/d/phobos/std_boxer.html --- dmd-0.129/dmd/html/d/phobos/std_boxer.html 1970-01-01 01:00:00.000000000 +0100 +++ dmd-0.130/dmd/html/d/phobos/std_boxer.html 2005-08-22 22:42:58.000000000 +0200 @@ -0,0 +1,327 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Phobos Runtime Library - std.boxer + + + + +www.digitalmars.com + +Home +| Search +| D +| Comments + +
    +Last update Mon Aug 22 2005 +


    + + + +
    +
    +
    + + + + + +
    +
    +
    D
    +
    Language
    +
    Phobos
    +
    Comparisons


    + +object
    +
    + +std
    std.base64
    std.boxer
    std.compiler
    std.conv
    std.ctype
    std.date
    std.file
    std.format
    std.gc
    std.intrinsic
    std.math
    std.md5
    std.mmfile
    std.openrj
    std.outbuffer
    std.path
    std.process
    std.random
    std.recls
    std.regexp
    std.socket
    std.socketstream
    std.stdint
    std.stdio
    std.cstream
    std.stream
    std.string
    std.system
    std.thread
    std.uri
    std.utf
    std.zip
    std.zlib
    +
    +std.windows
    +
    +std.linux
    +
    +std.c
    std.c.stdio
    +
    +std.c.windows
    +
    +std.c.linux
    +
    +
    +
    + + + + +

    std.boxer

    + + This module is a set of types and functions for converting any object + (value or heap) into a generic box type, allowing the user to pass that + object around without knowing what's in the box, and then allowing him + to recover the value afterwards. +

    + + Example + +

    +
    +
    
    +    // Convert the integer 45 into a box.
    +    Box b = box(45);
    +    
    +    // Recover the integer and cast it to real.
    +    real r = unbox!(real)(b);
    +    

    +

    + + That is the basic interface and will usually be all that you need to + understand. If it cannot unbox the object to the given type, it throws + UnboxException. As demonstrated, it uses implicit casts to behave in the + exact same way that static types behave. So for example, you can unbox + from int to real, but you cannot unbox from real to int: that would + require an explicit cast. +

    + + This therefore means that attempting to unbox an int as a string will + throw an error instead of formatting it. In general, you can call the + toString method on the box and receive a good result, depending upon + whether std.string.format accepts it. +

    + + Boxes can be compared to one another and they can be used as keys for + associative arrays. +

    + + There are also functions for converting to and from arrays of boxes. +

    + + Example +

    +
    +
    
    +    // Convert arguments into an array of boxes.
    +    Box[] a = boxArray(1, 45.4, "foobar");
    +    
    +    // Convert an array of boxes back into arguments.
    +    TypeInfo[] arg_types;
    +    void* arg_data;
    +    
    +    boxArrayToArguments(a, arg_types, arg_data);
    +    
    +    // Convert the arguments back into boxes using a
    +    // different form of the function.
    +    a = boxArray(arg_types, arg_data);
    +    

    + + One use of this is to support a variadic function more easily and + robustly; simply call "boxArray(_arguments, _argptr)", then + do whatever you need to do with the array. + +

    + +
    struct Box +
    Box is a generic container for objects (both value and + heap), allowing the user to box them in a generic form and recover + them later. +

    +

    +
    TypeInfo type +
    Property for the type contained by the box. This is + initially null and cannot be assigned directly. +

    + +

    void* data +
    Property for the data pointer to the value of the box. This is + initially null and cannot be assigned directly. +

    + +

    bit unboxable(TypeInfo type) +
    Return whether the value could be unboxed as the given type without + throwing an error. +

    + +

    char[] toString() +
    Attempt to convert the boxed value into a string using + std.string.format; this will throw if that function cannot handle + it. If the box is uninitialized then this returns "". +

    + +

    bit opEquals(Box other) +
    Compare this box's value with another box. This implicitly casts + if the types are different, identical to the regular type system. +

    + +

    float opCmp(Box other) +
    Compare this box's value with another box. This implicitly casts + if the types are different, identical to the regular type system. +

    + +

    uint toHash() +
    Return the value's hash. +

    +

    + +
    Box box(...) +
    Box the single argument passed to the function. If more or + fewer than one argument is passed, this will assert. +

    + +

    Box box(TypeInfo type, void* data) +
    Box the explicitly-defined object. type must not be null; data + must not be null if the type's size is greater than zero. +

    + + +

    Box[] boxArray(TypeInfo[] types, void* data) +
    Box[] boxArray(...) +
    Convert a list of arguments into a list of boxes. +

    + +

    void boxArrayToArguments(Box[] arguments, out TypeInfo[] types, out void* data) +
    Convert a list of boxes into a list of arguments. +

    + +

    bit unboxable!(T)(Box value) +
    Return whether the value can be unboxed as the given type; if this + returns false, attempting to do so will throw UnboxException. +

    + +

    T unbox!(T)(Box value) +
    This template function converts a boxed value into the provided + type. To use it, instantiate the template with the desired result + type, and then call the function with the box to convert. +

    + + This will implicitly cast base types as necessary and in a way + consistent with static types - for example, it will cast a boxed byte + into int, but it won't cast a boxed float into short. If it cannot + cast, it throws UnboxException. +

    + + Example
    +

    +
    +
    
    +    Box b = box(4.5);
    +    bit u = unboxable!(real)(b); // This is true.
    +    real r = unbox!(real)(b);
    +    

    + +

    class UnboxException : Error +
    This class is thrown if unbox is unable to cast the value into the + desired result. +

    +

    +
    this(Box object, TypeInfo outputType) +
    Assign parameters and create the message in the + form "Could not unbox from type to ." +

    + +

    box object +
    This is the box that the user attempted to unbox. +

    + +

    TypeInfo outputType +
    This is the type that the user attempted to unbox the value as. +
    + +
    + +
    +

    Feedback and Comments

    + + Add feedback and comments regarding this + page. + +
    +Copyright © 1999-2005 by Digital Mars, All Rights Reserved

    + + + + + + + + + + diff -uNr dmd-0.129/dmd/html/d/phobos/std_compiler.html dmd-0.130/dmd/html/d/phobos/std_compiler.html --- dmd-0.129/dmd/html/d/phobos/std_compiler.html 1970-01-01 01:00:00.000000000 +0100 +++ dmd-0.130/dmd/html/d/phobos/std_compiler.html 2005-08-22 22:42:58.000000000 +0200 @@ -0,0 +1,190 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Digital Mars - The D Programming Language - std.compiler + + + + +www.digitalmars.com + +Home +| Search +| D +| Comments + +
    +Last update Mon Aug 22 2005 +


    + + + +
    +
    +
    + + + + + +
    +
    +
    D
    +
    Language
    +
    Phobos
    +
    Comparisons


    + +object
    +
    + +std
    std.base64
    std.boxer
    std.compiler
    std.conv
    std.ctype
    std.date
    std.file
    std.format
    std.gc
    std.intrinsic
    std.math
    std.md5
    std.mmfile
    std.openrj
    std.outbuffer
    std.path
    std.process
    std.random
    std.recls
    std.regexp
    std.socket
    std.socketstream
    std.stdint
    std.stdio
    std.cstream
    std.stream
    std.string
    std.system
    std.thread
    std.uri
    std.utf
    std.zip
    std.zlib
    +
    +std.windows
    +
    +std.linux
    +
    +std.c
    std.c.stdio
    +
    +std.c.windows
    +
    +std.c.linux
    +
    +
    +
    + + +

    std.compiler

    + + +
    + +
    char[] name; +
    Vendor specific string naming the compiler, + for example: "Digital Mars D". +

    + +

    enum Vendor +
    Master list of D compiler vendors. +
    +
    DigitalMars +
    Digital Mars +
    +

    + +

    Vendor vendor; +
    Which vendor produced this compiler. +

    + +

    uint version_major; +
    uint version_minor; +
    The vendor specific version number, as in + version_major.version_minor. +

    + +

    uint D_major; +
    uint D_minor; +
    The version of the D Programming Language Specification + supported by the compiler. +

    + +

    + + +
    +

    Feedback and Comments

    + + Add feedback and comments regarding this + page. + +
    +Copyright © 1999-2005 by Digital Mars, All Rights Reserved

    + + + + + + + + + + + + + diff -uNr dmd-0.129/dmd/html/d/phobos/std_conv.html dmd-0.130/dmd/html/d/phobos/std_conv.html --- dmd-0.129/dmd/html/d/phobos/std_conv.html 1970-01-01 01:00:00.000000000 +0100 +++ dmd-0.130/dmd/html/d/phobos/std_conv.html 2005-08-22 22:42:58.000000000 +0200 @@ -0,0 +1,213 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Digital Mars - The D Programming Language - std.conv + + + + +www.digitalmars.com + +Home +| Search +| D +| Comments + +
    +Last update Mon Aug 22 2005 +


    + + + +
    +
    +
    + + + + + +
    +
    +
    D
    +
    Language
    +
    Phobos
    +
    Comparisons


    + +object
    +
    + +std
    std.base64
    std.boxer
    std.compiler
    std.conv
    std.ctype
    std.date
    std.file
    std.format
    std.gc
    std.intrinsic
    std.math
    std.md5
    std.mmfile
    std.openrj
    std.outbuffer
    std.path
    std.process
    std.random
    std.recls
    std.regexp
    std.socket
    std.socketstream
    std.stdint
    std.stdio
    std.cstream
    std.stream
    std.string
    std.system
    std.thread
    std.uri
    std.utf
    std.zip
    std.zlib
    +
    +std.windows
    +
    +std.linux
    +
    +std.c
    std.c.stdio
    +
    +std.c.windows
    +
    +std.c.linux
    +
    +
    +
    + + +

    std.conv

    + + std.conv provides basic building blocks for conversions from + strings to integral types. They differ from the C functions atoi() + and atol() by not allowing whitespace or overflows. +

    + + For conversion to signed types, the grammar recognized is: + +

    +	Integer:
    +		Sign UnsignedInteger
    +		UnsignedInteger
    +
    +	Sign:
    +		+
    +		-
    +	
    + + For conversion to unsigned types, the grammar recognized is: + +
    +	UnsignedInteger:
    +		DecimalDigit
    +		DecimalDigit UnsignedInteger
    +	
    + + Any deviation from that grammar causes a ConvError exception + to be thrown. Any overflows cause a ConvOverflowError to + be thrown. +
    + +
    byte toByte(char[] s) +

    + +

    ubyte toUbyte(char[] s) +

    + +

    short toShort(char[] s) +

    + +

    ushort toUshort(char[] s) +

    + +

    int toInt(char[] s) +

    + +

    uint toUint(char[] s) +

    + +

    long toLong(char[] s) +

    + +

    ulong toUlong(char[] s) +

    + +

    + + + +
    +

    Feedback and Comments

    + + Add feedback and comments regarding this + page. + +
    +Copyright © 1999-2005 by Digital Mars, All Rights Reserved

    + + + + + + + + + + + + + diff -uNr dmd-0.129/dmd/html/d/phobos/std_cstream.html dmd-0.130/dmd/html/d/phobos/std_cstream.html --- dmd-0.129/dmd/html/d/phobos/std_cstream.html 1970-01-01 01:00:00.000000000 +0100 +++ dmd-0.130/dmd/html/d/phobos/std_cstream.html 2005-08-22 22:42:58.000000000 +0200 @@ -0,0 +1,201 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Digital Mars - The D Programming Language - std.cstream + + + + +www.digitalmars.com + +Home +| Search +| D +| Comments + +
    +Last update Mon Aug 22 2005 +


    + + + +
    +
    +
    + + + + + +
    +
    +
    D
    +
    Language
    +
    Phobos
    +
    Comparisons


    + +object
    +
    + +std
    std.base64
    std.boxer
    std.compiler
    std.conv
    std.ctype
    std.date
    std.file
    std.format
    std.gc
    std.intrinsic
    std.math
    std.md5
    std.mmfile
    std.openrj
    std.outbuffer
    std.path
    std.process
    std.random
    std.recls
    std.regexp
    std.socket
    std.socketstream
    std.stdint
    std.stdio
    std.cstream
    std.stream
    std.string
    std.system
    std.thread
    std.uri
    std.utf
    std.zip
    std.zlib
    +
    +std.windows
    +
    +std.linux
    +
    +std.c
    std.c.stdio
    +
    +std.c.windows
    +
    +std.c.linux
    +
    +
    +
    + + +

    std.cstream

    + + + +The std.cstream module bridges std.c.stdio (or std.stdio) and std.stream. Both std.c.stdio and std.stream are publically imported by std.cstream. + +
    +
    class CFile : Stream +
    A Stream wrapper for a C file of type FILE*. +

    + +

    +
    this(FILE* file, FileMode mode, bool seekable = false) +
    Create the stream wrapper for the given C file. The mode + parameter is a bitwise combination of FileMode.In for + a readable file and FileMode.Out for a writeable file. + The seekable parameter indicates if the stream should be seekable. +

    + +

    ~this() +
    Closes the stream +

    +

    FILE* file +
    Property to get or sets the underlying file for this stream. + Setting the file marks the stream as open. +

    +

    void flush() +
    void close() +
    size_t readBlock(void* buffer, size_t size) +
    size_t writeBlock(void* buffer, size_t size) +
    ulong seek(long offset, SeekPos rel) +
    char getc() +
    char ungetc(char c) +
    bool eof() +
    void writeLine(char[] s) +
    void writeLineW(wchar[] s) +
    Overrides of the Stream methods to call the underlying + FILE* C functions. +
    +
    CFile din +
    CFile wrapper of std.c.stdio.stdin (not seekable). +
    CFile dout +
    CFile wrapper of std.c.stdio.stdout (not seekable). +
    CFile derr +
    CFile wrapper of std.c.stdio.stderr (not seekable). +
    + +
    +

    Feedback and Comments

    + + Add feedback and comments regarding this + page. + +
    +Copyright © 1999-2005 by Digital Mars, All Rights Reserved

    + + + + + + + + + + + + + + diff -uNr dmd-0.129/dmd/html/d/phobos/std_ctype.html dmd-0.130/dmd/html/d/phobos/std_ctype.html --- dmd-0.129/dmd/html/d/phobos/std_ctype.html 1970-01-01 01:00:00.000000000 +0100 +++ dmd-0.130/dmd/html/d/phobos/std_ctype.html 2005-08-22 22:42:58.000000000 +0200 @@ -0,0 +1,221 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Digital Mars - The D Programming Language - std.ctype + + + + +www.digitalmars.com + +Home +| Search +| D +| Comments + +
    +Last update Mon Aug 22 2005 +


    + + + +
    +
    +
    + + + + + +
    +
    +
    D
    +
    Language
    +
    Phobos
    +
    Comparisons


    + +object
    +
    + +std
    std.base64
    std.boxer
    std.compiler
    std.conv
    std.ctype
    std.date
    std.file
    std.format
    std.gc
    std.intrinsic
    std.math
    std.md5
    std.mmfile
    std.openrj
    std.outbuffer
    std.path
    std.process
    std.random
    std.recls
    std.regexp
    std.socket
    std.socketstream
    std.stdint
    std.stdio
    std.cstream
    std.stream
    std.string
    std.system
    std.thread
    std.uri
    std.utf
    std.zip
    std.zlib
    +
    +std.windows
    +
    +std.linux
    +
    +std.c
    std.c.stdio
    +
    +std.c.windows
    +
    +std.c.linux
    +
    +
    +
    + + +

    std.ctype

    + + +
    + +
    int isalnum(dchar c) +
    Returns !=0 if c is a letter or a digit. +

    + +

    int isalpha(dchar c) +
    Returns !=0 if c is an upper or lower case letter. +

    + +

    int iscntrl(dchar c) +
    Returns !=0 if c is a control character. +

    + +

    int isdigit(dchar c) +
    Returns !=0 if c is a digit. +

    + +

    int isgraph(dchar c) +
    Returns !=0 if c is a printing character except for the space character. +

    + +

    int islower(dchar c) +
    Returns !=0 if c is lower case. +

    + +

    int isprint(dchar c) +
    Returns !=0 if c is a printing character or a space. +

    + +

    int ispunct(dchar c) +
    Returns !=0 if c is a punctuation character. +

    + +

    int isspace(dchar c) +
    Returns !=0 if c is a space, tab, vertical tab, form feed, + carriage return, or linefeed. +

    + +

    int isupper(dchar c) +
    Returns !=0 if c is an upper case character. +

    + +

    int isxdigit(dchar c) +
    Returns !=0 if c is a hex digit (0..9, a..f, A..F). +

    + +

    int isascii(dchar c) +
    Returns !=0 if c is in the ascii character set. +

    + +

    dchar tolower(dchar c) +
    If c is upper case, return the lower case equivalent, + otherwise return c. +

    + +

    dchar toupper(dchar c) +
    If c is lower case, return the upper case equivalent, + otherwise return c. +

    + + +

    + + +
    +

    Feedback and Comments

    + + Add feedback and comments regarding this + page. + +
    +Copyright © 1999-2005 by Digital Mars, All Rights Reserved

    + + + + + + + + + + + + + diff -uNr dmd-0.129/dmd/html/d/phobos/std_date.html dmd-0.130/dmd/html/d/phobos/std_date.html --- dmd-0.129/dmd/html/d/phobos/std_date.html 1970-01-01 01:00:00.000000000 +0100 +++ dmd-0.130/dmd/html/d/phobos/std_date.html 2005-08-22 22:42:58.000000000 +0200 @@ -0,0 +1,247 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Digital Mars - The D Programming Language - std.date + + + + +www.digitalmars.com + +Home +| Search +| D +| Comments + +
    +Last update Mon Aug 22 2005 +


    + + + +
    +
    +
    + + + + + +
    +
    +
    D
    +
    Language
    +
    Phobos
    +
    Comparisons


    + +object
    +
    + +std
    std.base64
    std.boxer
    std.compiler
    std.conv
    std.ctype
    std.date
    std.file
    std.format
    std.gc
    std.intrinsic
    std.math
    std.md5
    std.mmfile
    std.openrj
    std.outbuffer
    std.path
    std.process
    std.random
    std.recls
    std.regexp
    std.socket
    std.socketstream
    std.stdint
    std.stdio
    std.cstream
    std.stream
    std.string
    std.system
    std.thread
    std.uri
    std.utf
    std.zip
    std.zlib
    +
    +std.windows
    +
    +std.linux
    +
    +std.c
    std.c.stdio
    +
    +std.c.windows
    +
    +std.c.linux
    +
    +
    +
    + + +

    std.date

    + + Dates are represented in several formats. The date implementation + revolves around a central type, d_time, from which other + formats are converted to and from. +

    + +

    +
    typedef d_time +
    Is a signed arithmetic type giving the time elapsed since + January 1, 1970. Negative values are for dates preceding 1970. + The time unit used is Ticks. Ticks are milliseconds + or smaller intervals. +

    + + The usual arithmetic operations can be performed on d_time, + such as adding, subtracting, etc. Elapsed time in Ticks can + be computed by subtracting a starting d_time from an ending + d_time. +

    + + An invalid value for d_time is represented by d_time.init. +

    + +

    int TicksPerSecond +
    A constant giving the number of Ticks per second for + this implementation. It will be at least 1000. +

    + +

    char[] toString(d_time t) +
    Converts t into a text string of the form: + "Www Mmm dd hh:mm:ss GMT+-TZ yyyy", + for example, "Tue Apr 02 02:04:57 GMT-0800 1996". + If t is invalid, "Invalid date" is returned. +

    + +

    char[] toUTCString(d_time t) +
    Converts t into a text string of the form: + "Www, dd Mmm yyyy hh:mm:ss UTC". + If t is invalid, "Invalid date" is returned. +

    + +

    char[] toDateString(d_time t) +
    Converts the date portion of t + into a text string of the form: + "Www Mmm dd yyyy", + for example, "Tue Apr 02 1996". + If t is invalid, "Invalid date" is returned. +

    + +

    char[] toTimeString(d_time t) +
    Converts the time portion of t + into a text string of the form: + "hh:mm:ss GMT+-TZ", + for example, "02:04:57 GMT-0800". + If t is invalid, "Invalid date" is returned. +

    + +

    d_time parse(char[] s) +
    Parses s as a textual date string, and + returns it as a d_time. If the string is not + a valid date, d_time.init is returned. +

    + +

    void toISO8601YearWeek(d_time t, out int year, out int week) +
    Compute year and week [1..53] from t. + The ISO 8601 week 1 is the first week of the year that includes + January 4. Monday is the first day of the week. +

    + +

    d_time getUTCtime() +
    Get current UTC time. +

    + +

    d_time UTCtoLocalTime(d_time t) +
    Convert from UTC time to local time. +

    + +

    d_time LocalTimetoUTC(d_time t) +
    Convert from local time to UTC time. +

    + +

    typedef DosFileTime +
    Type representing the DOS file date/time format. +

    + +

    d_time toDtime(DosFileTime time) +
    Convert from DOS file date/time to d_time. +

    + +

    DosFileTime toDosFileTime(d_time t) +
    Convert from d_time to DOS file date/time. + +
    + + +
    +

    Feedback and Comments

    + + Add feedback and comments regarding this + page. + +
    +Copyright © 1999-2005 by Digital Mars, All Rights Reserved

    + + + + + + + + + + + diff -uNr dmd-0.129/dmd/html/d/phobos/std_file.html dmd-0.130/dmd/html/d/phobos/std_file.html --- dmd-0.129/dmd/html/d/phobos/std_file.html 1970-01-01 01:00:00.000000000 +0100 +++ dmd-0.130/dmd/html/d/phobos/std_file.html 2005-08-22 22:42:58.000000000 +0200 @@ -0,0 +1,228 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Digital Mars - The D Programming Language - std.file + + + + +www.digitalmars.com + +Home +| Search +| D +| Comments + +
    +Last update Mon Aug 22 2005 +


    + + + +
    +
    +
    + + + + + +
    +
    +
    D
    +
    Language
    +
    Phobos
    +
    Comparisons


    + +object
    +
    + +std
    std.base64
    std.boxer
    std.compiler
    std.conv
    std.ctype
    std.date
    std.file
    std.format
    std.gc
    std.intrinsic
    std.math
    std.md5
    std.mmfile
    std.openrj
    std.outbuffer
    std.path
    std.process
    std.random
    std.recls
    std.regexp
    std.socket
    std.socketstream
    std.stdint
    std.stdio
    std.cstream
    std.stream
    std.string
    std.system
    std.thread
    std.uri
    std.utf
    std.zip
    std.zlib
    +
    +std.windows
    +
    +std.linux
    +
    +std.c
    std.c.stdio
    +
    +std.c.windows
    +
    +std.c.linux
    +
    +
    +
    + + +

    std.file

    + +
    + +
    class FileException +
    Exception thrown if file I/O errors. +

    + +

    void[] read(char[] name) +
    Read file name[], return array of bytes read. +

    + +

    void write(char[] name, void[] buffer) +
    Write buffer[] to file name[]. +

    + +

    void append(char[] name, void[] buffer) +
    Append buffer[] to file name[]. +

    + +

    void rename(char[] from, char[] to) +
    Rename file from[] to to[]. +

    + +

    void copy(char[] from, char[] to) +
    Copy file from[] to to[]. +

    + +

    void remove(char[] name) +
    Delete file name[]. +

    + +

    uint getSize(char[] name) +
    Get size of file name[]. +

    + +

    uint getAttributes(char[] name) +
    Get file name[] attributes. +

    + +

    int exists(char[] name) +
    Does name[] exist (file or directory)? +

    + +

    int isfile(char[] name) +
    Is name[] a file? Error if name[] doesn't exist. +

    + +

    int isdir(char[] name) +
    Is name[] a directory? Error if name[] doesn't exist. +

    + +

    void chdir(char[] name) +
    Change directory. +

    + +

    void mkdir(char[] name) +
    Make directory. +

    + +

    void rmdir(char[] name) +
    Remove directory. +

    + +

    char[] getcwd() +
    Get current directory. +

    + +

    char[][] listdir(char[] pathname) +
    Return contents of directory. +

    + + +

    + + +
    +

    Feedback and Comments

    + + Add feedback and comments regarding this + page. + +
    +Copyright © 1999-2005 by Digital Mars, All Rights Reserved

    + + + + + + + + + + + + diff -uNr dmd-0.129/dmd/html/d/phobos/std_format.html dmd-0.130/dmd/html/d/phobos/std_format.html --- dmd-0.129/dmd/html/d/phobos/std_format.html 1970-01-01 01:00:00.000000000 +0100 +++ dmd-0.130/dmd/html/d/phobos/std_format.html 2005-08-22 22:42:58.000000000 +0200 @@ -0,0 +1,446 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Digital Mars - The D Programming Language - std.format + + + + +www.digitalmars.com + +Home +| Search +| D +| Comments + +
    +Last update Mon Aug 22 2005 +


    + + + +
    +
    +
    + + + + + +
    +
    +
    D
    +
    Language
    +
    Phobos
    +
    Comparisons


    + +object
    +
    + +std
    std.base64
    std.boxer
    std.compiler
    std.conv
    std.ctype
    std.date
    std.file
    std.format
    std.gc
    std.intrinsic
    std.math
    std.md5
    std.mmfile
    std.openrj
    std.outbuffer
    std.path
    std.process
    std.random
    std.recls
    std.regexp
    std.socket
    std.socketstream
    std.stdint
    std.stdio
    std.cstream
    std.stream
    std.string
    std.system
    std.thread
    std.uri
    std.utf
    std.zip
    std.zlib
    +
    +std.windows
    +
    +std.linux
    +
    +std.c
    std.c.stdio
    +
    +std.c.windows
    +
    +std.c.linux
    +
    +
    +
    + + +

    std.format

    + + + +This module implements the workhorse functionality for string and I/O +formatting. It's comparable to C99's vsprintf(). + +
    +
    class FormatError; +
    Signals a mismatch between a format and its corresponding argument. +

    + +

    void doFormat(void delegate(dchar) putc, TypeInfo[] arguments, va_list argptr); +
    Interprets variadic argument list pointed to by argptr + whose types are given by arguments[], formats them + according to embedded format strings in the variadic argument + list, and sends the resulting characters to putc. + Mismatched arguments and formats result in a FormatError + being thrown. +

    + + The variadic arguments are consumed in order. + Each is formatted into a sequence of chars, + using the default format specification for its type, + and the + characters are sequentially passed to putc. + If a char[], wchar[], or dchar[] argument is + encountered, it is + interpreted as a format string. As many arguments as + specified in the format string are consumed and formatted + according to the + format specifications in that string and passed to + putc. + If there are too few remaining arguments, a FormatError + is thrown. + If there are more remaining arguments than needed by the + format specification, the default processing of arguments + resumes until they are all consumed. +

    + + Any strings used as formats or that are output, and any characters, + must be valid UTF characters. + +

    + +

    Format String

    + + Format strings consist of characters interspersed with + format specifications. Characters are simply copied + to the output (such as putc) after any necessary conversion + to the corresponding UTF-8 sequence. +

    + + A format specification starts with a '%' character, + and has the following grammar: + +

    +	FormatSpecification:
    +	    '%%'
    +	    '%' Flags Width Precision FormatChar
    +
    +	Flags:
    +	    empty
    +	    '-' Flags
    +	    '+' Flags
    +	    '#' Flags
    +	    '0' Flags
    +	    ' ' Flags
    +
    +	Width:
    +	    empty
    +	    Integer
    +	    '*'
    +
    +	Precision:
    +	    empty
    +	    '.'
    +	    '.' Integer
    +	    '.*'
    +
    +	Integer:
    +	    Digit
    +	    Digit Integer
    +
    +	Digit:
    +	    '0'
    +	    '1'
    +	    '2'
    +	    '3'
    +	    '4'
    +	    '5'
    +	    '6'
    +	    '7'
    +	    '8'
    +	    '9'
    +
    +	FormatChar:
    +	    's'
    +	    'b'
    +	    'd'
    +	    'o'
    +	    'x'
    +	    'X'
    +	    'e'
    +	    'E'
    +	    'f'
    +	    'F'
    +	    'g'
    +	    'G'
    +	    'a'
    +	    'A'
    +	
    + +
    +
    Flags +
    +
    '-' +
    + Left justify the result in the field. + It overrides any 0 flag. +

    + +

    '+' +
    Prefix positive numbers in a signed conversion with a +. + It overrides any space flag. +

    + +

    '#' +
    Use alternative formatting: +
    +
    For 'o': +
    Add to precision as necessary so that the first digit + of the octal formatting is a '0', even if both the argument + and the Precision are zero. +
    For 'x' ('X'): +
    If non-zero, prefix result with 0x (0X). +
    For floating point formatting: +
    Always insert the decimal point. +
    For 'g' ('G'): +
    Do not elide trailing zeros. +
    +

    + +

    '0' +
    For integer and floating point formatting when not nan or + infinity, use leading zeros + to pad rather than spaces. + Ignore if there's a Precision. +

    + +

    ' ' +
    Prefix positive numbers in a signed conversion with a space. +

    +

    +

    + +

    Width +
    + Specifies the minimum field width. + If the width is a *, the next argument, which must be + of type int, is taken as the width. + If the width is negative, it is as if the - was given + as a Flags character. +

    + +

    Precision +
    Gives the precision for numeric conversions. + If the precision is a *, the next argument, which must be + of type int, is taken as the precision. If it is negative, + it is as if there was no Precision. +

    + +

    FormatChar +
    +
    +
    's' +
    The corresponding argument is formatted in a manner consistent + with its type: +
    +
    bit +
    The result is 'true' or 'false'. +
    integral types +
    The %d format is used. +
    floating point types +
    The %g format is used. +
    string types +
    The result is the string converted to UTF-8. + A Precision specifies the maximum number of characters + to use in the result. +
    classes derived from Object +
    The result is the string returned from the class instance's + .toString() method. + A Precision specifies the maximum number of characters + to use in the result. +
    non-string static and dynamic arrays +
    The result is [s0, s1, ...] + where sk is the kth element + formatted with the default format. +
    +

    + +

    'b','d','o','x','X' +
    The corresponding argument must be an integral type + and is formatted as an integer. If the argument is a signed type + and the FormatChar is d it is converted to + a signed string of characters, otherwise it is treated as + unsigned. An argument of type bit is formatted as '1' + or '0'. The base used is binary for b, octal for o, + decimal + for d, and hexadecimal for x or X. + x formats using lower case letters, X uppercase. + If there are fewer resulting digits than the Precision, + leading zeros are used as necessary. + If the Precision is 0 and the number is 0, no digits + result. +

    + +

    'e','E' +
    A floating point number is formatted as one digit before + the decimal point, Precision digits after, the FormatChar, + ±, followed by at least a two digit exponent: d.dddddde±dd. + If there is no Precision, six + digits are generated after the decimal point. + If the Precision is 0, no decimal point is generated. +

    + +

    'f','F' +
    A floating point number is formatted in decimal notation. + The Precision specifies the number of digits generated + after the decimal point. It defaults to six. At least one digit + is generated before the decimal point. If the Precision + is zero, no decimal point is generated. +

    + +

    'g','G' +
    A floating point number is formatted in either e or + f format for g; E or F format for + G. + The f format is used if the exponent for an e format + is greater than -5 and less than the Precision. + The Precision specifies the number of significant + digits, and defaults to one. + Trailing zeros are elided after the decimal point, if the fractional + part is zero then no decimal point is generated. +

    + +

    'a','A' +
    A floating point number is formatted in hexadecimal + exponential notation 0xh.hhhhhhp±d. + There is one hexadecimal digit before the decimal point, and as + many after as specified by the Precision. + If the Precision is zero, no decimal point is generated. + If there is no Precision, as many hexadecimal digits as + necessary to exactly represent the mantissa are generated. + The exponent is written in as few digits as possible, + but at least one, is in decimal, and represents a power of 2 as in + h.hhhhhh*2±d. + The exponent for zero is zero. + The hexadecimal digits, x and p are in upper case if the + FormatChar is upper case. +
    +

    + + Floating point NaN'ss are formatted as nan if the + FormatChar is lower case, or NAN if upper. + Floating point infinities are formatted as inf or + infinity if the + FormatChar is lower case, or INF or INFINITY if upper. + +

    + +

    Example

    + +
    +	import std.c.stdio;
    +	import std.format;
    +
    +	void formattedPrint(...)
    +	{
    +	    void putc(char c)
    +	    {
    +		fputc(c, stdout);
    +	    }
    +
    +	    std.format.doFormat(&putc, _arguments, _argptr);
    +	}
    +
    +	...
    +
    +	int x = 27;
    +	formattedPrint("The answer is %s:", x, 6); // prints 'The answer is 27:6'
    +	
    + + +
    +

    Feedback and Comments

    + + Add feedback and comments regarding this + page. + +
    +Copyright © 1999-2005 by Digital Mars, All Rights Reserved

    + + + + + + + + + + + + diff -uNr dmd-0.129/dmd/html/d/phobos/std_gc.html dmd-0.130/dmd/html/d/phobos/std_gc.html --- dmd-0.129/dmd/html/d/phobos/std_gc.html 1970-01-01 01:00:00.000000000 +0100 +++ dmd-0.130/dmd/html/d/phobos/std_gc.html 2005-08-22 22:42:58.000000000 +0200 @@ -0,0 +1,235 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Digital Mars - The D Programming Language - std.gc + + + + +www.digitalmars.com + +Home +| Search +| D +| Comments + +
    +Last update Mon Aug 22 2005 +


    + + + +
    +
    +
    + + + + + +
    +
    +
    D
    +
    Language
    +
    Phobos
    +
    Comparisons


    + +object
    +
    + +std
    std.base64
    std.boxer
    std.compiler
    std.conv
    std.ctype
    std.date
    std.file
    std.format
    std.gc
    std.intrinsic
    std.math
    std.md5
    std.mmfile
    std.openrj
    std.outbuffer
    std.path
    std.process
    std.random
    std.recls
    std.regexp
    std.socket
    std.socketstream
    std.stdint
    std.stdio
    std.cstream
    std.stream
    std.string
    std.system
    std.thread
    std.uri
    std.utf
    std.zip
    std.zlib
    +
    +std.windows
    +
    +std.linux
    +
    +std.c
    std.c.stdio
    +
    +std.c.windows
    +
    +std.c.linux
    +
    +
    +
    + + +

    std.gc

    + + + The garbage collector normally works behind the scenes without + needing any specific interaction. These functions are for + advanced applications that benefit from tuning the operation of the + collector. + +
    +
    class OutOfMemory +
    Thrown if garbage collector runs out of memory. +

    + +

    void addRoot(void* p) +
    Add p to list of roots. Roots are references to memory + allocated by the collector that are maintained in memory + outside the collector pool. The garbage collector will by + default look for roots in the stacks of each thread, the registers, + and the default static data segment. If roots are held elsewhere, + use addRoot() or addRange() to tell the collector + not to free the memory it points to. +

    + +

    void removeRoot(void* p) +
    Remove p from list of roots. +

    + +

    void addRange(void* pbot, void* ptop) +
    Add range to scan for roots. +

    + +

    void removeRange(void* pbot) +
    Remove range. +

    + +

    void fullCollect() +
    Run a full garbage collection cycle. + The collector normally runs synchronously with a storage + allocation request (i.e. it never happens when in code that + does not allocate memory). In some circumstances, for example + when a particular task is finished, it is convenient to explicitly + run the collector and free up all memory used by that task. + It can also be helpful to run a collection before starting a new + task that would be annoying if it ran a collection in + the middle of that task. + Explicitly running a collection can also be done in a separate very low priority + thread, so that if the program is idly waiting for input, memory + can be cleaned up. +

    + + +

    void genCollect() +
    Run a generational garbage collection cycle. + Takes less time than a fullCollect(), but isn't + as effective. +

    + +

    void minimize() +
    Minimize physical memory usage. +

    + + +

    void disable() +
    Temporarilly disable garbage collection cycle. + This is used for brief time critical sections of code, + so the amount of time it will take is predictable. + If the collector runs out of memory while it is disabled, + it will throw an OutOfMemory exception. + The disable() function calls can be nested, but must be + matched with corresponding enable() calls. +

    + + +

    void enable() +
    Reenable garbage collection cycle after being disabled + with disable(). + It is an error to call more enable()s than + disable()s. + +
    + + +
    +

    Feedback and Comments

    + + Add feedback and comments regarding this + page. + +
    +Copyright © 1999-2005 by Digital Mars, All Rights Reserved

    + + + + + + + + + + + + + diff -uNr dmd-0.129/dmd/html/d/phobos/std_intrinsic.html dmd-0.130/dmd/html/d/phobos/std_intrinsic.html --- dmd-0.129/dmd/html/d/phobos/std_intrinsic.html 1970-01-01 01:00:00.000000000 +0100 +++ dmd-0.130/dmd/html/d/phobos/std_intrinsic.html 2005-08-22 22:42:58.000000000 +0200 @@ -0,0 +1,307 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Digital Mars - The D Programming Language - std.intrinsic + + + + +www.digitalmars.com + +Home +| Search +| D +| Comments + +
    +Last update Mon Aug 22 2005 +


    + + + +
    +
    +
    + + + + + +
    +
    +
    D
    +
    Language
    +
    Phobos
    +
    Comparisons


    + +object
    +
    + +std
    std.base64
    std.boxer
    std.compiler
    std.conv
    std.ctype
    std.date
    std.file
    std.format
    std.gc
    std.intrinsic
    std.math
    std.md5
    std.mmfile
    std.openrj
    std.outbuffer
    std.path
    std.process
    std.random
    std.recls
    std.regexp
    std.socket
    std.socketstream
    std.stdint
    std.stdio
    std.cstream
    std.stream
    std.string
    std.system
    std.thread
    std.uri
    std.utf
    std.zip
    std.zlib
    +
    +std.windows
    +
    +std.linux
    +
    +std.c
    std.c.stdio
    +
    +std.c.windows
    +
    +std.c.linux
    +
    +
    +
    + + +

    std.intrinsic

    + + + Intrinsic functions are functions built in to the compiler, + usually to take advantage of specific CPU features that + are inefficient to handle via external functions. + The compiler's optimizer and code generator are fully + integrated in with intrinsic functions, bringing to bear + their full power on them. + This can result in some surprising speedups. + +
    + +
    int bsf(uint v) +
    Scans the bits in v starting with bit 0, looking + for the first set bit. + +
    int bsr(uint v) +
    Scans the bits in v from the most significant bit + to the least significant bit, looking + for the first set bit. +

    + + Both return the bit number of the first set bit. + The return value is undefined if v is zero. +

    + + Example
    + +

    +
    +
    
    +	import std.intrinsic;
    +
    +	int main()
    +	{   
    +	    uint v;
    +	    int x;
    +
    +	    v = 0x21;
    +	    x = bsf(v);
    +	    printf("bsf(x%x) = %d\n", v, x);
    +	    x = bsr(v);
    +	    printf("bsr(x%x) = %d\n", v, x);
    +	    return 0;
    +	} 
    +	

    + + Output
    +

    +	bsf(x21) = 0
    +	bsr(x21) = 5
    +	
    + +
    int bt(uint* p, uint index) +
    Tests the bit. + +
    int btc(uint* p, uint index) +
    Tests and complements the bit. + +
    int btr(uint* p, uint index) +
    Tests and resets (sets to 0) the bit. + +
    int bts(uint* p, uint index) +
    Tests and sets the bit. +

    + + p is a non-NULL pointer to an array of uints. + index is a bit number, starting with bit 0 of p[0], + and progressing. It addresses bits like the expression: +

    +	p[index / (uint.size*8)] & (1 << (index & ((uint.size*8) - 1)))
    +	
    +

    + + All return a non-zero value if the bit was set, and a zero + if it was clear. +

    + + Example + +

    +
    +
    
    +	import std.intrinsic;
    +
    +	int main()
    +	{   
    +	    uint array[2];
    +
    +	    array[0] = 2;
    +	    array[1] = 0x100;
    +
    +	    printf("btc(array, 35) = %d\n", btc(array, 35));
    +	    printf("array = [0]:x%x, [1]:x%x\n", array[0], array[1]);
    +
    +	    printf("btc(array, 35) = %d\n", btc(array, 35));
    +	    printf("array = [0]:x%x, [1]:x%x\n", array[0], array[1]);
    +
    +	    printf("bts(array, 35) = %d\n", bts(array, 35));
    +	    printf("array = [0]:x%x, [1]:x%x\n", array[0], array[1]);
    +
    +	    printf("btr(array, 35) = %d\n", btr(array, 35));
    +	    printf("array = [0]:x%x, [1]:x%x\n", array[0], array[1]);
    +
    +	    printf("bt(array, 1) = %d\n", bt(array, 1));
    +	    printf("array = [0]:x%x, [1]:x%x\n", array[0], array[1]);
    +
    +	    return 0;
    +	} 
    +

    + + Output +

    +	btc(array, 35) = 0
    +	array = [0]:x2, [1]:x108
    +	btc(array, 35) = -1
    +	array = [0]:x2, [1]:x100
    +	bts(array, 35) = 0
    +	array = [0]:x2, [1]:x108
    +	btr(array, 35) = -1
    +	array = [0]:x2, [1]:x100
    +	bt(array, 1) = -1
    +	array = [0]:x2, [1]:x100
    +
    +
    uint bswap(uint x) +
    Swaps bytes in a 4 byte uint end-to-end, i.e. byte 0 becomes + byte 3, byte 1 becomes byte 2, byte 2 becomes byte 1, byte 3 + becomes byte 0. +

    + +

    ubyte inp(uint port_address) +
    ushort inpw(uint port_address) +
    uint inpl(uint port_address) +
    Reads I/O port at port_address. +

    + +

    ubyte outp(uint port_address, ubyte value) +
    ushort outpw(uint port_address, ushort value) +
    uint outpl(uint port_address, uint value) +
    Writes and returns value to I/O port at port_address. +

    + +

    real cos(real) +
    real fabs(real) +
    real rint(real) +
    long rndtol(real) +
    real sin(real) +
    real sqrt(real) +
    Intrinsic verions of the math functions of the same name. + +
    + + +
    +

    Feedback and Comments

    + + Add feedback and comments regarding this + page. + +
    +Copyright © 1999-2005 by Digital Mars, All Rights Reserved

    + + + + + + + + + + + + + diff -uNr dmd-0.129/dmd/html/d/phobos/std_math.html dmd-0.130/dmd/html/d/phobos/std_math.html --- dmd-0.129/dmd/html/d/phobos/std_math.html 1970-01-01 01:00:00.000000000 +0100 +++ dmd-0.130/dmd/html/d/phobos/std_math.html 2005-08-22 22:42:58.000000000 +0200 @@ -0,0 +1,472 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Digital Mars - The D Programming Language - std.math + + + + +www.digitalmars.com + +Home +| Search +| D +| Comments + +
    +Last update Mon Aug 22 2005 +


    + + + +
    +
    +
    + + + + + +
    +
    +
    D
    +
    Language
    +
    Phobos
    +
    Comparisons


    + +object
    +
    + +std
    std.base64
    std.boxer
    std.compiler
    std.conv
    std.ctype
    std.date
    std.file
    std.format
    std.gc
    std.intrinsic
    std.math
    std.md5
    std.mmfile
    std.openrj
    std.outbuffer
    std.path
    std.process
    std.random
    std.recls
    std.regexp
    std.socket
    std.socketstream
    std.stdint
    std.stdio
    std.cstream
    std.stream
    std.string
    std.system
    std.thread
    std.uri
    std.utf
    std.zip
    std.zlib
    +
    +std.windows
    +
    +std.linux
    +
    +std.c
    std.c.stdio
    +
    +std.c.windows
    +
    +std.c.linux
    +
    +
    +
    + + +

    std.math

    + +
    + +
    const real PI +
    const real LOG2 +
    const real LN2 +
    const real LOG2T +
    const real LOG2E +
    const real E +
    const real LOG10E +
    const real LN10 +
    const real PI_2 +
    const real PI_4 +
    const real M_1_PI +
    const real M_2_PI +
    const real M_2_SQRTPI +
    const real SQRT2 +
    const real SQRT1_2 +
    Math constants. +

    + +

    real acos(real) +
    real asin(real) +
    real atan(real) +
    real atan2(real, real) +

    + +

    real cos(real x) +
    Compute cosine of x. x is in radians.
    + Special values: + + + +
    x + return value + invalid? +
    ±∞ + NAN + yes +
    +

    + +

    real sin(real x) +
    Compute sine of x. x is in radians.
    + Special values: + + + + +
    x + return value + invalid? +
    ±0.0 + ±0.0 + no +
    ±∞ + NAN + yes +
    +

    + +

    real tan(real x) +
    Compute tangent of x. x is in radians.
    + Special values: + + + + +
    x + return value + invalid? +
    ±0.0 + ±0.0 + no +
    ±∞ + NAN + yes +
    +

    + +

    real cosh(real) +
    real sinh(real) +
    real tanh(real) +
    real exp(real) +

    + +

    real frexp(real value, out int exp) +
    Calculate and return x and exp such that:
    + value=x*2exp
    + .5 <= |x| < 1.0
    + x has same sign as value. +
    + Special values: + + + + + + +
    value x exp +
    ±0.0 ±0.0 0 +
    +∞ +∞ int.max +
    -∞ -∞ int.min +
    ±NAN ±NAN int.min +
    +

    + +

    real ldexp(real n, int exp) +
    Compute n * 2exp +

    + +

    real log(real x) +
    Calculate the natural logarithm of x. +
    + Special values: + + + + + +
    x return value divide by 0? invalid? +
    ±0.0 -∞ yes no +
    < 0.0 NAN no yes +
    +∞ +∞ no no +
    +

    + +

    real log10(real x) +
    Calculate the base-10 logarithm of x. +
    + Special values: + + + + + +
    x return value divide by 0? invalid? +
    ±0.0 -∞ yes no +
    < 0.0 NAN no yes +
    +∞ +∞ no no +
    +

    + +

    real modf(real, real*) +

    + +

    real pow(real, real) +

    + +

    real sqrt(real x) +
    creal sqrt(creal x) +
    Compute square root of x.
    + Special values: + + + + + +
    x + return value + invalid? +
    -0.0 + -0.0 + no +
    <0.0 + NAN + yes +
    +∞ + +∞ + no +
    +

    + +

    real ceil(real) +
    real floor(real) +

    + +

    real log1p(real x) +
    Calculates the natural logarithm of + 1 + x. + For very small x, log1p(x) will be more accurate than + log(1 + x). +
    + Special values: + + + + + + +
    x + log1p(x) + divide by 0? + invalid? +
    ±0.0 + ±0.0 + no + no +
    -1.0 + -∞ + yes + no +
    <-1.0 + NAN + no + yes +
    +∞ + -∞ + no + no +
    +

    + +

    real expm1(real x) +
    Calculates the value of the natural logarithm base (e) + raised to the power of x, minus 1. + For very small x, expm1(x) is more accurate + than exp(x)-1. +
    + Special values: + + + + + +
    x + ex-1 +
    ±0.0 + ±0.0 +
    +∞ + +∞ +
    -∞ + -1.0 +
    +

    + +

    real atof(char*) +
    Math functions. +

    + +

    real hypot(real x, real y) +
    + Calculates the length of the + hypotenuse of a right-angled triangle with sides of length x and y. + The hypotenuse is the value of the square root of + the sums of the squares of x and y: +
    +	sqrt(x2 + y2)
    + Note that hypot(x,y), hypot(y,x) and + hypot(x,-y) are equivalent.
    + Special values: + + + + + +
    x + y + return value + invalid? +
    x + ±0.0 + fabs(x) + no +
    ±∞ + y + +∞ + no +
    ±∞ + NAN + +∞ + no +
    +

    + +

    int isnan(real e) +
    Is number a nan? +

    + +

    int isfinite(real e) +
    Is number finite? +

    + +

    int isnormal(float f) +
    int isnormal(double d) +
    int isnormal(real e) +
    Is number normalized? +

    + +

    int issubnormal(float f) +
    int issubnormal(double d) +
    int issubnormal(real e) +
    Is number subnormal? (Also called "denormal".) + Subnormals have a 0 exponent and a 0 most significant mantissa bit. +

    + +

    int isinf(real e) +
    Is number infinity? +

    + +

    int signbit(real e) +
    Get sign bit. +

    + +

    real copysign(real to, real from) +
    Copy sign. +

    + +

    int feqrel(real x, real y) +
    To what precision is x equal to y?
    + Returns the number of mantissa bits which are equal in x and y. + eg, 0x1.F8p+60 and 0x1.F1p+60 are equal to 5 bits of precision.
    + If x == y, then feqrel(x, y) == real.mant_dig.
    + If x and y differ by a factor of two or more, or if one or both + is a nan, the return value is 0. +

    + +

    + + +
    +

    Feedback and Comments

    + + Add feedback and comments regarding this + page. + +
    +Copyright © 1999-2005 by Digital Mars, All Rights Reserved

    + + + + + + + + + + + diff -uNr dmd-0.129/dmd/html/d/phobos/std_md5.html dmd-0.130/dmd/html/d/phobos/std_md5.html --- dmd-0.129/dmd/html/d/phobos/std_md5.html 1970-01-01 01:00:00.000000000 +0100 +++ dmd-0.130/dmd/html/d/phobos/std_md5.html 2005-08-22 22:42:58.000000000 +0200 @@ -0,0 +1,247 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Digital Mars - The D Programming Language - std.md5 + + + + +www.digitalmars.com + +Home +| Search +| D +| Comments + +
    +Last update Mon Aug 22 2005 +


    + + + +
    +
    +
    + + + + + +
    +
    +
    D
    +
    Language
    +
    Phobos
    +
    Comparisons


    + +object
    +
    + +std
    std.base64
    std.boxer
    std.compiler
    std.conv
    std.ctype
    std.date
    std.file
    std.format
    std.gc
    std.intrinsic
    std.math
    std.md5
    std.mmfile
    std.openrj
    std.outbuffer
    std.path
    std.process
    std.random
    std.recls
    std.regexp
    std.socket
    std.socketstream
    std.stdint
    std.stdio
    std.cstream
    std.stream
    std.string
    std.system
    std.thread
    std.uri
    std.utf
    std.zip
    std.zlib
    +
    +std.windows
    +
    +std.linux
    +
    +std.c
    std.c.stdio
    +
    +std.c.windows
    +
    +std.c.linux
    +
    +
    +
    + + +

    std.md5

    + + +Computes MD5 digests of arbitrary data. MD5 digests are 16 byte quantities +that are like a checksum or crc, but are more robust. +

    +There are two ways to do this. The first does it all in one function call +to sum(). The second is for when the data is buffered. +

    +The routines and algorithms are derived from the +RSA Data Security, Inc. MD5 Message-Digest Algorithm. +

    + +

    +
    void sum(ubyte[16] digest, void[] data) +
    Compute MD5 digest from data. +

    + +

    void printDigest(ubyte[16] digest) +
    Print MD5 digest to standard output. +

    + +

    struct MD5_CTX +
    Use when data to be digested is buffered. +

    + +

    + +
    void start() +
    Begins an MD5 message-digest operation. +

    + +

    void update(void[] input) +
    Continues an MD5 message-digest + operation, processing another message block input, + and updating the context. +

    + +

    void finish(ubyte[16] digest) +
    Ends an MD5 message-digest operation and writes the result + to digest. + +
    + +
    + + +

    Example

    + +

    +
    +
    
    +// This code is derived from the
    +// RSA Data Security, Inc. MD5 Message-Digest Algorithm.
    +
    +import std.md5;
    +import std.string;
    +import std.c.stdio;
    +
    +int main(char[][] args)
    +{
    +    for (int i = 1; i < args.length; i++)
    +	 MDFile(args[i]);
    +    return 0;
    +}
    +
    +/* Digests a file and prints the result. */
    +void MDFile(char[] filename)
    +{
    +    FILE* file;
    +    MD5_CTX context;
    +    int len;
    +    ubyte [4 * 1024] buffer;
    +    ubyte digest[16];
    +
    +    if ((file = fopen(std.string.toStringz(filename), "rb")) == null)
    +	printf("%.*s can't be opened\n", filename);
    +    else
    +    {
    +	context.start();
    +	while ((len = fread(buffer, 1, buffer.size, file)) != 0)
    +	    context.update(buffer[0 .. len]);
    +	context.finish(digest);
    +	fclose(file);
    +
    +	printf("MD5 (%.*s) = ", filename);
    +	printDigest(digest);
    +	printf("\n");
    +    }
    +}
    +

    + + + +

    +

    Feedback and Comments

    + + Add feedback and comments regarding this + page. + +
    +Copyright © 1999-2005 by Digital Mars, All Rights Reserved

    + + + + + + + + + + + + + diff -uNr dmd-0.129/dmd/html/d/phobos/std_mmfile.html dmd-0.130/dmd/html/d/phobos/std_mmfile.html --- dmd-0.129/dmd/html/d/phobos/std_mmfile.html 1970-01-01 01:00:00.000000000 +0100 +++ dmd-0.130/dmd/html/d/phobos/std_mmfile.html 2005-08-22 22:42:58.000000000 +0200 @@ -0,0 +1,253 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Digital Mars - The D Programming Language - std.mmfile + + + + +www.digitalmars.com + +Home +| Search +| D +| Comments + +
    +Last update Mon Aug 22 2005 +


    + + + +
    +
    +
    + + + + + +
    +
    +
    D
    +
    Language
    +
    Phobos
    +
    Comparisons


    + +object
    +
    + +std
    std.base64
    std.boxer
    std.compiler
    std.conv
    std.ctype
    std.date
    std.file
    std.format
    std.gc
    std.intrinsic
    std.math
    std.md5
    std.mmfile
    std.openrj
    std.outbuffer
    std.path
    std.process
    std.random
    std.recls
    std.regexp
    std.socket
    std.socketstream
    std.stdint
    std.stdio
    std.cstream
    std.stream
    std.string
    std.system
    std.thread
    std.uri
    std.utf
    std.zip
    std.zlib
    +
    +std.windows
    +
    +std.linux
    +
    +std.c
    std.c.stdio
    +
    +std.c.windows
    +
    +std.c.linux
    +
    +
    +
    + + +

    std.mmfile

    + + + +Read and write memory mapped files. + +
    + +
    class MmFile +
    MmFile objects control the memory mapped file resource. + Any errors detected by + the MmFile objects will throw an instance of + std.file.FileException. +

    + +

    + +
    enum Mode +
    The mode the memory mapped file is opened with: +

    +

    +
    Read +
    read existing file +
    ReadWriteNew +
    delete existing file, write new file +
    ReadWrite +
    read/write existing file, create if not existing +
    ReadCopyOnWrite +
    read/write existing file, copy on write +
    +

    + +

    this(char[] filename); +
    Open memory mapped file filename for reading. + File is closed when the object instance is deleted. +

    + +

    this(char[] filename, Mode mode, size_t size, void* address); +
    Open memory mapped file filename in mode. + File is closed when the object instance is deleted.
    + filename gives the name of the file. If null, an + anonymous file mapping is created.
    + mode gives the access mode defined above.
    + size gives the size of the file. If 0, it is taken to + be the size of the existing file.
    + address gives the preferred address to map the file to, + allthough the system is not required to honor it. If + null, the system selects the most convenient address. +

    + +

    ~this() +
    Flushes pending output and closes the memory mapped file. +

    + +

    void flush() +
    Flushes pending output. +

    + +

    Mode mode() +
    Read-only property returning the file mode. +

    + +

    size_t length() +
    Gives size in bytes of the memory mapped file. +

    +

    + +
    Operator overloads +

    + +

    + +
    void[] opSlice() +
    Returns entire file contents as an array. +

    + +

    void[] opSlice(size_t i1, size_t i2) +
    Returns slice of file contents as an array. +

    + +

    ubyte opIndex(size_t i) +
    Returns byte at index i in file. +

    + +

    ubyte opIndex(size_t i, ubyte value) +
    Returns sets byte at index i in file to value. +

    + + +

    + +
    + +

    Notes

    + +
      +
    • Won't work with files larger than the address space. +
    + + +
    +

    Feedback and Comments

    + + Add feedback and comments regarding this + page. + +
    +Copyright © 1999-2005 by Digital Mars, All Rights Reserved

    + + + + + + + + + + + + + diff -uNr dmd-0.129/dmd/html/d/phobos/std_openrj.html dmd-0.130/dmd/html/d/phobos/std_openrj.html --- dmd-0.129/dmd/html/d/phobos/std_openrj.html 1970-01-01 01:00:00.000000000 +0100 +++ dmd-0.130/dmd/html/d/phobos/std_openrj.html 2005-08-22 22:42:58.000000000 +0200 @@ -0,0 +1,585 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Digital Mars - The D Programming Language - std.openrj + + + + +www.digitalmars.com + +Home +| Search +| D +| Comments + +
    +Last update Mon Aug 22 2005 +


    + + + +
    +
    +
    + + + + + +
    +
    +
    D
    +
    Language
    +
    Phobos
    +
    Comparisons


    + +object
    +
    + +std
    std.base64
    std.boxer
    std.compiler
    std.conv
    std.ctype
    std.date
    std.file
    std.format
    std.gc
    std.intrinsic
    std.math
    std.md5
    std.mmfile
    std.openrj
    std.outbuffer
    std.path
    std.process
    std.random
    std.recls
    std.regexp
    std.socket
    std.socketstream
    std.stdint
    std.stdio
    std.cstream
    std.stream
    std.string
    std.system
    std.thread
    std.uri
    std.utf
    std.zip
    std.zlib
    +
    +std.windows
    +
    +std.linux
    +
    +std.c
    std.c.stdio
    +
    +std.c.windows
    +
    +std.c.linux
    +
    +
    +
    + + +

    std.openrj

    + + + +Open-RJ is an open-source library that implements readers of the Record-Jar +structured text file format, designed and implemented by Matthew Wilson, as an +exemplar project for his column Positive Integration in +C/C++ Users Journal. +

    +It is implemented in C & C++, with a C-API. +The implementation of the basic library is platform-independent. Mappings are +provided to several languages (including C++, +D, +Ruby +and +STL), +and others (COM, Java, .NET, Perl, Python) are planned. In addition to +platform-independence, the library focuses on small runtime +costs - memory and speed - and the classic UNIX attributes of +discoverability and visibility. +

    + +

    What is the Record-Jar format?

    +

    +As described in the excellent book +"The Art Of UNIX Programming", a Record-Jar structured format file +consists of records and fields. +

    +

    +A field is a single line - optionally extended with trailing '\' - that contains +a name, separated from an optional value by ':'. +

    +

    +A record is a list of fields, whose contents are arbitrary and can vary between +records in the same database. Records are separated by a line that begins with +"%%". The record separator also acts as a comment, so +anything can come on a record separator line after the first two characters. +

    +

    +A database is a correctly parsed Record-Jar file. The Open-RJ API (and language +mappings) provide access to all the records in the database and the complete set +of fields. Hence, you may work with fields on a per-record basis, or treat the database +as a single record and with all fields in the database. +

    +

    +A very simple Record-Jar file, representing a Pets Database, is shown below: +

    + +
    +Name:       Elsa
    +Species:    Dog
    +Breed:      Mixed
    +%%
    +Name:       Fluffy Kitten
    +Species:    Cat
    +%%
    +Name:       Rebel
    +Species:    Dog
    +Breed:      German 
    +            Shepherd
    +%%
    +Name:       Pepper
    +Species:    Dog
    +Breed:      Border Collie
    +%%
    +Name:       Samson
    +Species:    Dog
    +Breed:      Ridgeback
    +%%
    +Name:       Sheltie
    +Species:    Dog
    +Breed:      Shetland 
    +            Sheepdog
    +%%
    +Name:       Sparky
    +Species:    Cat
    +%%
    +
    + +

    +And that's pretty much all there is to it. There are no restrictions on what fields may +be in a record, and no controls over whether all records have the same fields or not. +That's the job of higher layers of application functionality. We keep Record-Jar simple +so it's reliable, portable and fast, and it's those things in spades! +

    + +

    std.openrj

    +

    +The D mapping of Open-RJ is packaged with Phobos in the std.openrj +module. It consists of four classes: +

    + +and one enumeration: + + +The basic usage is as follows: +
      +
    1. + Create a database instance, on an existing Open-RJ database file, e.g. +
      +    char[]   contents = cast(char[])(std.file.read("pets.orj"));
      +    Database db       = new Database(contents, ORJ_FLAG.ELIDE_BLANK_RECORDS);
      +  
      +
    2. +
    3. + Enumerate over the records in the database, by using foreach: +
      +    foreach(Record r; db)
      +    {
      +      . . . // Process the record
      +    }
      +  
      + or by indexed lookup (which returns a Record instance): +
      +    for(int i = 0; i < db.length; ++i)
      +    {
      +      Record r = db[i];
      +
      +      . . . // Process the record
      +    }
      +  
      +

      + Processing of the record may be done by either ... +

      +
    4. +
    5. + ... enumerating the fields in the record, by using foreach: +
      +    foreach(Field f; r)
      +    {
      +      char[] name  = f.name;
      +      char[] value = f.value;
      +
      +      printf("  %.*s=%.*s\n", name, value);  // e.g. "Breed=German Shepherd"
      +    }
      +  
      + or by indexed lookup (which returns a Field instance): +
      +    for(int i = 0; i < r.length; ++i)
      +    {
      +      Field f = r[i];
      +
      +      . . . // Process the field
      +    }
      +  
      +
    6. +
    7. + ... or it might be by field lookup or by name (which returns a string): +
      +    printf("  The value of the \"Species\" field is %.*s\n", r["Species"]);
      +  
      +
    8. +
    +

    + + +

    std.openrj.Database

    + The Database class has the following methods: +
    +
    +
    this(in char[] contents, in uint flags = 0)
    +
    Create a database object representing the given database contents +

    +

    contents The contents (or full path) of the database, where lines are separated by carriage-returns
    +
    flags A combination of ORJ_FLAG flags + which affect the processing of the Jar file
    +

    +

    Note: throws a DatabaseException + if the contents do not represent a + correctly formed Open-RJ database
    +

    + +

    this(in char[][] lines, in uint flags = 0)
    +
    Create a database object representing the given database contents +

    +

    lines The database contents as an array of lines
    +
    flags A combination of ORJ_FLAG flags + which affect the processing of the Jar file
    +

    +

    Note: throws a DatabaseException + if the contents do not represent a + correctly formed Open-RJ database
    +

    + +

    Record opIndex(uint index)
    +
    The record at the given index
    +

    +

    Note: the function gives undefined behaviour if the index is invalid
    +

    + + +

    Record[] getRecordsContainingField(char[] fieldName)
    +
    Returns an array of all records that contain a Field + with the given name
    +

    +

    fieldName The name of the field
    +

    + +

    Record[] getRecordsContainingField(char[] fieldName, char[] fieldValue)
    +
    Returns an array of all records that contain a Field + with the given name and value
    +

    +

    fieldName The name of the field
    +
    fieldValue The value of the field. May be null, in which case the semantics + are identical to getRecordsContainingField
    +

    + +

    +
    + and the following attributes: +
    +
    +
    char[] jarName()
    +
    The name of the database Jar file
    +

    + +

    uint flags()
    +
    The flags specified in the constructor
    +

    + +

    Record[] records()
    +
    An array of all records in the database
    +

    + +

    Field[] fields()
    +
    An array of all fields in the database
    +

    + +

    uint numFields()
    +
    The number of fields in the database
    +

    + +

    uint numRecords()
    +
    The number of records in the database
    +

    + +

    uint length()
    +
    The number of records in the database
    +

    + +

    +
    +

    + + +

    std.openrj.Record

    + The Record class has the following methods: +
    +
    +
    Field opIndex(uint index)
    +
    Returns the field at the given index
    +

    +

    Note: the function gives undefined behaviour if the index is invalid
    +

    + +

    char[] opIndex(char[] fieldName)
    +
    Returns the value of the (first) field with the given name
    +

    +

    fieldName The name of the field
    +

    +

    Note: throws an InvalidKeyException if no field is found
    +

    + +

    Field getField(char[] fieldName)
    +
    Returns the (first) field with the given name
    +

    +

    fieldName The name of the field
    +

    +

    Note: throws an InvalidKeyException if no field is found
    +

    + +

    Field findField(char[] fieldName)
    +
    Returns the (first) field with the given name
    +

    +

    fieldName The name of the field
    +

    +

    Note: return null if no field is found
    +

    + +

    bool hasField(char[] fieldName)
    +
    Returns true if the record contains one or more fields with the given name
    +

    +

    fieldName The name of the field
    +

    + +

    +
    + and the following attributes: +
    +
    +
    Field[] fields()
    +
    An array of all fields in the record
    +

    + +

    uint numFields()
    +
    The number of fields in the record
    +

    + +

    uint length()
    +
    The number of fields in the record
    +

    + +

    Database database()
    +
    The database within which the record resides
    +

    + +

    +
    +

    + + +

    std.openrj.Field

    + The Field class has the following properties: + methods: +
    +
    +
    char[] name()
    +
    The name of the field
    +

    + +

    char[] value()
    +
    The value of the field
    +

    + +

    Record record()
    +
    The record within which the field resides. May be null
    +

    + +

    +
    +

    + + +

    std.openrj.OpenRJException

    + Base exception class used by the openrj module. +

    + + +

    std.openrj.DatabaseException

    + Exception class, derived from OpenRJException, + thrown if the database Jar file cannot be opened, or its contents do not represent a + correctly formed Open-RJ database. +

    + The DatabaseException class has the following properties: + methods: +

    +
    +
    ORJRC rc()
    +
    The general error code associated with the exception
    +

    + +

    ORJ_PARSE_ERROR parseError()
    +
    The parsing error code associated with the exception
    +

    + +

    int lineNum()
    +
    The lineNum associated with the exception
    +

    + +

    +
    +

    + + +

    std.openrj.InvalidKeyException

    + Exception class, derived from OpenRJException, + thrown when named fields are not found. +

    + + +

    std.openrj.ORJ_FLAG

    + Enumeration, whose values control the loading behaviour of the + Database class. +
    +
    +
    ORDER_FIELDS - Arranges the fields in alphabetical order
    +
    ELIDE_BLANK_RECORDS - Causes blank records to be ignored
    +
    +
    +

    + + +

    std.openrj.ORJRC

    + Enumeration representing general database processing errors encountered in + the loading of the Database class. +
    +
    +
    SUCCESS - Operation was successful
    +
    CANNOT_OPEN_JAR_FILE - The given file does not exist, or cannot be accessed
    +
    NO_RECORDS - The database file contained no records
    +
    OUT_OF_MEMORY - The API suffered memory exhaustion
    +
    BAD_FILE_READ - A read operation failed
    +
    PARSE_ERROR - Parsing of the database file failed due to a syntax error
    +
    INVALID_INDEX - An invalid index was specified
    +
    UNEXPECTED - An unexpected condition was encountered
    +
    INVALID_CONTENT - The database file contained invalid content
    +
    +
    +

    + + +

    std.openrj.ORJ_PARSE_ERROR

    + Enumeration representing database parsing errors encountered in + the loading of the Database class. +
    +
    +
    SUCCESS - Parsing was successful
    +
    RECORD_SEPARATOR_IN_CONTINUATION - A record separator was encountered during a content line continuation
    +
    UNFINISHED_LINE - The last line in the database was not terminated by a line-feed
    +
    UNFINISHED_FIELD - The last field in the database file was not terminated by a record separator
    +
    UNFINISHED_RECORD - The last record in the database file was not terminated by a record separator
    +
    +
    +

    + +


    Copyright (c) 2004-2005 by Matthew Wilson, Synesis Software Pty Ltd, All Rights Reserved + +
    +

    Feedback and Comments

    + + Add feedback and comments regarding this + page. + +
    +Copyright © 1999-2005 by Digital Mars, All Rights Reserved

    + + + + + + + + + + + + + diff -uNr dmd-0.129/dmd/html/d/phobos/std_outbuffer.html dmd-0.130/dmd/html/d/phobos/std_outbuffer.html --- dmd-0.129/dmd/html/d/phobos/std_outbuffer.html 1970-01-01 01:00:00.000000000 +0100 +++ dmd-0.130/dmd/html/d/phobos/std_outbuffer.html 2005-08-22 22:42:58.000000000 +0200 @@ -0,0 +1,239 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Digital Mars - The D Programming Language - std.outbuffer + + + + +www.digitalmars.com + +Home +| Search +| D +| Comments + +
    +Last update Mon Aug 22 2005 +


    + + + +
    +
    +
    + + + + + +
    +
    +
    D
    +
    Language
    +
    Phobos
    +
    Comparisons


    + +object
    +
    + +std
    std.base64
    std.boxer
    std.compiler
    std.conv
    std.ctype
    std.date
    std.file
    std.format
    std.gc
    std.intrinsic
    std.math
    std.md5
    std.mmfile
    std.openrj
    std.outbuffer
    std.path
    std.process
    std.random
    std.recls
    std.regexp
    std.socket
    std.socketstream
    std.stdint
    std.stdio
    std.cstream
    std.stream
    std.string
    std.system
    std.thread
    std.uri
    std.utf
    std.zip
    std.zlib
    +
    +std.windows
    +
    +std.linux
    +
    +std.c
    std.c.stdio
    +
    +std.c.windows
    +
    +std.c.linux
    +
    +
    +
    + + +

    std.outbuffer

    + + + +
    + +
    class OutBuffer +
    OutBuffer provides a way to build up an array of bytes out + of raw data. It is useful for things like preparing an + array of bytes to write out to a file. + OutBuffer's byte order is the format native to the computer. + To control the byte order (endianness), use a class derived + from OutBuffer. + To convert an array of bytes back into raw data, use InBuffer. +

    + +

    + +
    void reserve(uint nbytes) +
    Preallocate nbytes more to the size of the internal + buffer. This is a speed optimization, a good guess at the maximum + size of the resulting buffer will improve performance by eliminating + reallocations and copying. +

    + +

    void write(ubyte[] bytes) +
    void write(ubyte b) +
    void write(byte b) +
    void write(char c) +
    void write(ushort w) +
    void write(short s) +
    void write(wchar c) +
    void write(uint w) +
    void write(int i) +
    void write(ulong l) +
    void write(long l) +
    void write(float f) +
    void write(double f) +
    void write(real f) +
    void write(char[] s) +
    void write(OutBuffer buf) +
    Append data to the internal buffer. +

    + +

    void fill0(uint nbytes) +
    Append nbytes of 0 to the internal buffer. +

    + +

    void alignSize(uint alignsize) +
    0-fill to align on an alignsize boundary. + alignsize must be a power of 2. +

    + +

    void align2() +
    Optimize common special case alignSize(2) +

    + +

    void align4() +
    Optimize common special case alignSize(4) +

    + +

    ubyte[] toBytes() +
    Convert internal buffer to array of bytes. +

    + +

    char[] toString() +
    Convert internal buffer to array of chars. +

    + +

    void vprintf(char[] format, va_list args) +
    Append output of vprintf() to internal buffer. +

    + +

    void printf(char[] format, ...) +
    Append output of printf() to internal buffer. +

    + +

    void spread(uint index, uint nbytes) +
    At offset index into buffer, create nbytes + of space by shifting upwards all data past index. +

    + +

    +
    + + +
    +

    Feedback and Comments

    + + Add feedback and comments regarding this + page. + +
    +Copyright © 1999-2005 by Digital Mars, All Rights Reserved

    + + + + + + + + + + + + + diff -uNr dmd-0.129/dmd/html/d/phobos/std_path.html dmd-0.130/dmd/html/d/phobos/std_path.html --- dmd-0.129/dmd/html/d/phobos/std_path.html 1970-01-01 01:00:00.000000000 +0100 +++ dmd-0.130/dmd/html/d/phobos/std_path.html 2005-08-22 22:42:58.000000000 +0200 @@ -0,0 +1,252 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Digital Mars - The D Programming Language - std.path + + + + +www.digitalmars.com + +Home +| Search +| D +| Comments + +
    +Last update Mon Aug 22 2005 +


    + + + +
    +
    +
    + + + + + +
    +
    +
    D
    +
    Language
    +
    Phobos
    +
    Comparisons


    + +object
    +
    + +std
    std.base64
    std.boxer
    std.compiler
    std.conv
    std.ctype
    std.date
    std.file
    std.format
    std.gc
    std.intrinsic
    std.math
    std.md5
    std.mmfile
    std.openrj
    std.outbuffer
    std.path
    std.process
    std.random
    std.recls
    std.regexp
    std.socket
    std.socketstream
    std.stdint
    std.stdio
    std.cstream
    std.stream
    std.string
    std.system
    std.thread
    std.uri
    std.utf
    std.zip
    std.zlib
    +
    +std.windows
    +
    +std.linux
    +
    +std.c
    std.c.stdio
    +
    +std.c.windows
    +
    +std.c.linux
    +
    +
    +
    + + +

    std.path

    + +
    + +
    const char[] sep; +
    Character used to separate directory names in a path. +

    + +

    const char[] altsep; +
    Alternate version of sep[], used in Windows. +

    + +

    const char[] pathsep; +
    Path separator string. +

    + +

    const char[] linesep; +
    String used to separate lines. +

    + +

    const char[] curdir; +
    String representing the current directory. +

    + +

    const char[] pardir; +
    String representing the parent directory. +

    + + +

    char[] getExt(char[] fullname) +
    Get extension. + For example, "d:\path\foo.bat" returns "bat". +

    + + +

    char[] getBaseName(char[] fullname) +
    Get base name. + For example, "d:\path\foo.bat" returns "foo.bat". +

    + + +

    char[] getDirName(char[] fullname) +
    Get directory name. + For example, "d:\path\foo.bat" returns "d:\path". +

    + + +

    char[] getDrive(char[] fullname) +
    Get drive. + For example, "d:\path\foo.bat" returns "d:". + Returns null string on systems without the concept of a drive. +

    + + +

    char[] defaultExt(char[] fullname, char[] ext) +
    Put a default extension on fullname if it doesn't already + have an extension. +

    + + +

    char[] addExt(char[] fullname, char[] ext) +
    Add file extension or replace existing extension. +

    + + +

    int isabs(char[] path) +
    Determine if absolute path name. +

    + + +

    char[] join(char[] p1, char[] p2) +
    Join two path components. +

    + + +

    int fncharmatch(dchar c1, dchar c2) +
    Match file name characters. + Case sensitivity depends on the operating system. +

    + + +

    int fnmatch(char[] name, char[] pattern) +
    Match filename strings with pattern[], using the following wildcards: +
    +
    * match 0 or more characters +
    ? match any character +
    [chars] match any character that appears between the [] +
    [!chars] match any character that does not appear between the [! ] +
    + Matching is case sensitive on a file system that is case sensitive.
    + Returns: +
    +
    !=0 match +
    0 no match +
    +

    + + +

    + + +
    +

    Feedback and Comments

    + + Add feedback and comments regarding this + page. + +
    +Copyright © 1999-2005 by Digital Mars, All Rights Reserved

    + + + + + + + + + + + diff -uNr dmd-0.129/dmd/html/d/phobos/std_process.html dmd-0.130/dmd/html/d/phobos/std_process.html --- dmd-0.129/dmd/html/d/phobos/std_process.html 1970-01-01 01:00:00.000000000 +0100 +++ dmd-0.130/dmd/html/d/phobos/std_process.html 2005-08-22 22:42:58.000000000 +0200 @@ -0,0 +1,177 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Digital Mars - The D Programming Language - std.process + + + + +www.digitalmars.com + +Home +| Search +| D +| Comments + +
    +Last update Mon Aug 22 2005 +


    + + + +
    +
    +
    + + + + + +
    +
    +
    D
    +
    Language
    +
    Phobos
    +
    Comparisons


    + +object
    +
    + +std
    std.base64
    std.boxer
    std.compiler
    std.conv
    std.ctype
    std.date
    std.file
    std.format
    std.gc
    std.intrinsic
    std.math
    std.md5
    std.mmfile
    std.openrj
    std.outbuffer
    std.path
    std.process
    std.random
    std.recls
    std.regexp
    std.socket
    std.socketstream
    std.stdint
    std.stdio
    std.cstream
    std.stream
    std.string
    std.system
    std.thread
    std.uri
    std.utf
    std.zip
    std.zlib
    +
    +std.windows
    +
    +std.linux
    +
    +std.c
    std.c.stdio
    +
    +std.c.windows
    +
    +std.c.linux
    +
    +
    +
    + + +

    std.process

    + + + +
    + +
    int system(char[] command) +
    Execute command in a command shell. + Returns exit status of command. +

    + +

    int execv(char[] program, char[][] arguments) +
    int execve(char[] program, char[][] arguments, char[][] environment) +
    int execvp(char[] program, char[][] arguments) +
    int execvpe(char[] program, char[][] arguments, char[][] environment) +
    Execute program, passing it the arguments + and the environment, returning the exit status. + The 'p' versions of exec search the PATH environment variable + setting for program. +

    + + +

    + + +
    +

    Feedback and Comments

    + + Add feedback and comments regarding this + page. + +
    +Copyright © 1999-2005 by Digital Mars, All Rights Reserved

    + + + + + + + + + + + + diff -uNr dmd-0.129/dmd/html/d/phobos/std_random.html dmd-0.130/dmd/html/d/phobos/std_random.html --- dmd-0.129/dmd/html/d/phobos/std_random.html 1970-01-01 01:00:00.000000000 +0100 +++ dmd-0.130/dmd/html/d/phobos/std_random.html 2005-08-22 22:42:58.000000000 +0200 @@ -0,0 +1,175 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Digital Mars - The D Programming Language - std.random + + + + +www.digitalmars.com + +Home +| Search +| D +| Comments + +
    +Last update Mon Aug 22 2005 +


    + + + +
    +
    +
    + + + + + +
    +
    +
    D
    +
    Language
    +
    Phobos
    +
    Comparisons


    + +object
    +
    + +std
    std.base64
    std.boxer
    std.compiler
    std.conv
    std.ctype
    std.date
    std.file
    std.format
    std.gc
    std.intrinsic
    std.math
    std.md5
    std.mmfile
    std.openrj
    std.outbuffer
    std.path
    std.process
    std.random
    std.recls
    std.regexp
    std.socket
    std.socketstream
    std.stdint
    std.stdio
    std.cstream
    std.stream
    std.string
    std.system
    std.thread
    std.uri
    std.utf
    std.zip
    std.zlib
    +
    +std.windows
    +
    +std.linux
    +
    +std.c
    std.c.stdio
    +
    +std.c.windows
    +
    +std.c.linux
    +
    +
    +
    + + +

    std.random

    + + +
    + +
    void rand_seed(uint seed, uint index) +
    The random number generator is seeded at program + startup with a random value. This ensures that each program + generates a different sequence of random numbers. + To generate a repeatable sequence, use rand_seed() to + start the sequence. seed and index start it, and each + successive value increments index. This means that the + nth random number of the sequence can be directly generated + by passing index + n to rand_seed(). +

    + +

    uint rand() +
    Get next random number in sequence. +

    + +

    + + +
    +

    Feedback and Comments

    + + Add feedback and comments regarding this + page. + +
    +Copyright © 1999-2005 by Digital Mars, All Rights Reserved

    + + + + + + + + + + + + diff -uNr dmd-0.129/dmd/html/d/phobos/std_recls.html dmd-0.130/dmd/html/d/phobos/std_recls.html --- dmd-0.129/dmd/html/d/phobos/std_recls.html 1970-01-01 01:00:00.000000000 +0100 +++ dmd-0.130/dmd/html/d/phobos/std_recls.html 2005-08-22 22:42:58.000000000 +0200 @@ -0,0 +1,470 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Digital Mars - The D Programming Language - std.recls + + + + +www.digitalmars.com + +Home +| Search +| D +| Comments + +
    +Last update Mon Aug 22 2005 +


    + + + +
    +
    +
    + + + + + +
    +
    +
    D
    +
    Language
    +
    Phobos
    +
    Comparisons


    + +object
    +
    + +std
    std.base64
    std.boxer
    std.compiler
    std.conv
    std.ctype
    std.date
    std.file
    std.format
    std.gc
    std.intrinsic
    std.math
    std.md5
    std.mmfile
    std.openrj
    std.outbuffer
    std.path
    std.process
    std.random
    std.recls
    std.regexp
    std.socket
    std.socketstream
    std.stdint
    std.stdio
    std.cstream
    std.stream
    std.string
    std.system
    std.thread
    std.uri
    std.utf
    std.zip
    std.zlib
    +
    +std.windows
    +
    +std.linux
    +
    +std.c
    std.c.stdio
    +
    +std.c.windows
    +
    +std.c.linux
    +
    +
    +
    + + +

    std.recls

    + + + +

    +recls - standing for recursive ls - is a platform-independent +recursive search library, designed and implemented by Matthew Wilson, as the first +exemplar project for his column Positive Integration in +C/C++ Users Journal. +

    +recls currently supports recursive searching of file systems (UNIX and Windows), and +FTP sites (currently Windows-only). Future enhancements may include recursive-searching of the +Windows registry, source-code control systems, and, of course, FTP-searching for UNIX platforms. +

    +recls is implemented in C++, using the +STLSoft +libraries (which are also bundled with Digital Mars; see +stlsoft.digitalmars.com), +and presents a C-API. recls is also mapped to a host of other languages and +technologies, including C++, COM, C#/.NET, Java, Ruby +and STL among an ever-expanding list. Given its non-trivial size, the recls D +mapping is a good place to learn about interfacing C libraries to D. +

    +The recls homepage is www.recls.org, +from which updates to the library, and all the other language mappings, may be obtained. Support +for recls has evolved to piggy-back on the +STLSoft newsgroup, although +questions about using recls in D should be directed through the main +D newsgroup, and bugs in +recls (in D) should be reported to the +D bugs newsgroup. +

    +The Windows version of the D mapping of recls uses a crude-but-adequate delay-loading +mechanism such that linking to WinInet.lib is not required. This strategy was necessitated by +D's linkage model, and was elected to avoid encumbering executables with something that they +may not use. There is are negative effects if the program explicitly uses WinInet.lib for +other aspects. +

    +The recls object model is comprised of the following classes: +

    +the enum RECLS_FLAG: + +and the following functions: + +

    +The basic usage is as follows: +

      +
    1. + Create a search instance, either FileSearch or + FtpSearch, e.g. +
      +    // Enumerate all the zip and exe files on the Digital Mars FTP server
      +    Search s = new FtpSearch("ftp.digitalmars.com", "anonymous", "", "/",
      +	"*.zip;*.exe", RECLS_FLAG.RECURSIVE | RECLS_FLAG.PASSIVE_FTP);
      +  
      + or +
      +    // Enumerate all the three-letter first-level sub-directories beginning
      +    // with s of H:\SynSoft\D\phobos\
      +    FileSearch s = new FileSearch("H:\SynSoft\D\phobos\", "s??",
      +	RECLS_FLAG.DIRECTORIES);
      +  
      +
    2. +
    3. + Enumerate the search instance, using foreach. +
      +    foreach(Entry e; s)
      +    {
      +      if(e.size < 2000)
      +      {
      +        writef(e.path);       // e.g. "/Digital_Mars_C++/STL"
      +        writef(e.directory);  // e.g. "/Digital_Mars_C++/STL"
      +        writef(e.file);       // e.g. "stlport.zip"
      +        writef(e.fileName);   // e.g. "stlport"
      +        writef(e.fileExt);    // e.g. "zip"
      +        ...
      +      }
      +    }
      +  
      + The many properties of the Entry class are used to provide + access to all attributes of file/directory entries. +
    4. +
    +

    + + +

    std.recls.Entry

    + The Entry class has the following properties: +
    +
    +
    char[] getPath()
    +
    char[] path()
    +
    The full path of the entry
    +

    + +

    char drive() - (Windows only)
    +
    The drive component of the entry's path
    +

    + +

    char[] directory()
    +
    The directory component of the entry's path
    +

    + +

    char[] directoryPath()
    +
    The full location component of the entry's path.
    +

    + +

    char[][] directoryParts()
    +
    An array of strings representing the parts of the Directory property
    +

    + +

    char[] file()
    +
    The file component of the entry's path
    +

    + +

    char[] shortFile()
    +
    The short equivalent of the entry's File property
    +

    + +

    char[] fileName()
    +
    The file name component of the entry's path
    +

    + +

    char[] fileExt()
    +
    The file extension component of the entry's path
    +

    + +

    d_time creationTime()
    +
    The time the entry was created
    +

    + +

    d_time modificationTime()
    +
    The time the entry was last modified
    +

    + +

    d_time lastAccessTime()
    +
    The time the entry was last accessed
    +

    + +

    d_time lastStatusChangeTime()
    +
    The time the entry's last status changed
    +

    + +

    recls_filesize_t fileSize()
    +
    The size of the entry
    +

    + +

    int isReadOnly()
    +
    Indicates whether the entry is read-only
    +

    + +

    int isDirectory()
    +
    Indicates whether the entry is a directory
    +

    + +

    int isLink()
    +
    Indicates whether the entry is a link
    +

    +

    +
    +

    + + +

    std.recls.FileSearch

    + The FileSearch class derives from the + Search class, and has the following + methods: +
    +
    +
    this(in char[] searchRoot, in char[] pattern, in uint flags)
    +
    Create a search object with the given searchRoot, pattern and flags +

    +

    searchRoot The root directory of the search. If null, or the empty string, the current directory is assumed
    +
    pattern The search pattern. If null all entries are returned (equivalent to specifying + wildcardsAll().) If the empty string, the search returns an empty result set. +
    flags A combination of RECLS_FLAG flags which moderate the search
    +

    +

    Note: pattern can be a composite pattern, e.g. "*.exe;*.zip;*.c??", but the separator must + be the correct one for the local operating system (see getPathSeparator()).
    +

    +

    +
    +

    + + +

    std.recls.FtpSearch

    + The FtpSearch class derives from the + Search class, and has the following + methods: +
    +
    +
    this(in char[] host, in char[] username, in char[] password, in char[] searchRoot, in char[] pattern, in uint flags)
    +
    Create a search object with the given searchRoot, pattern and flags +

    +

    host The name of the host providing the FTP service
    +
    username The username of the acount to use to log on to the FTP server
    +
    password The password of the acount to use to log on to the FTP server
    +
    searchRoot The root directory of the search. If null, or the empty string, the current directory is assumed
    +
    pattern The search pattern. If null all entries are returned (equivalent to specifying + wildcardsAll().) If the empty string, the search returns an empty result set. +
    flags A combination of RECLS_FLAG flags which moderate the search
    +

    +

    Note: pattern can be a composite pattern, e.g. "*.exe;*.zip;*.c??", but the separator must + be the correct one for the local operating system (see getPathSeparator()).
    +

    +

    +
    +

    + + +

    std.recls.ReclsException

    + Exception class used by the recls module. +

    + + +

    std.recls.Search

    + Base class of the FileSearch and + FtpSearch classes. Supports foreach. +

    + + +

    std.recls.RECLS_FLAG

    + Enumeration, whose values control the search behaviour provided by the + FileSearch and + FtpSearch classes. +
    +
    +
    FILES - Include files in search. Included by default if none specified
    +
    DIRECTORIES - Include directories in search. Not currently supported
    +
    LINKS - Include links in search. Ignored in Win32
    +
    DEVICES - Include devices in search. Not currently supported
    +
    RECURSIVE - Searches given directory and all sub-directories
    +
    NO_FOLLOW_LINKS - Does not expand links
    +
    DIRECTORY_PARTS - Fills out the directory parts. Supported from version 1.1.1 onwards
    +
    DETAILS_LATER - Does not fill out anything other than the path. Not currently supported
    +
    PASSIVE_FTP - Passive mode in FTP
    +
    +
    +

    + + +

    std.recls functions

    + Free functions provided by the recls module. +

    +

    +
    + +
    char[][] getRoots();
    +
    Returns an array of all file-system roots on the local system.
    +
    + On Unix, this always returns an array with a single entry which is "/". On Windows, + it will return an array of strings representing the drives, e.g. "C:", "D:", "H:", "Y:" +
    . +

    + + +

    char[] getPathNameSeparator();
    +
    Returns the symbol used to separate distinct path names in path name lists.
    +
    + On UNIX this is "/"; on Win32 it is "\". +
    . +

    + + +

    char[] getPathNameSeparator();
    +
    Returns the symbol used to separate the directory parts within paths.
    +
    + On UNIX this is ":"; on Win32 it is ";". +
    . +

    + + +

    char[] wildcardsAll();
    +
    Returns the wildcard symbol used to represent the "all files" for the current operating system.
    +
    + On UNIX this is "*"; on Win32 it is "*.*". +
    . +

    + + +

    int isDirectoryEmpty(char[] dir);
    +
    int isDirectoryEmpty(Entry dir);
    +
    + Determines whether the given directory is empty. +
    . +

    + + +

    recls_filesize_t calcDirectorySize(char[] dir, int bRecurse);
    +
    recls_filesize_t calcDirectorySize(Entry dir, int bRecurse);
    +
    + Determines the size of the given directory. If bRecurse is non-0, it calculates the size of all + sub-directories, otherwise it counts only the sizes of the files in the given directory. +
    . +

    + +

    +
    + + +
    Copyright (c) 2003-2004 by Matthew Wilson, Synesis Software Pty Ltd, All Rights Reserved + +
    +

    Feedback and Comments

    + + Add feedback and comments regarding this + page. + +
    +Copyright © 1999-2005 by Digital Mars, All Rights Reserved

    + + + + + + + + + + + diff -uNr dmd-0.129/dmd/html/d/phobos/std_regexp.html dmd-0.130/dmd/html/d/phobos/std_regexp.html --- dmd-0.129/dmd/html/d/phobos/std_regexp.html 1970-01-01 01:00:00.000000000 +0100 +++ dmd-0.130/dmd/html/d/phobos/std_regexp.html 2005-08-22 22:42:58.000000000 +0200 @@ -0,0 +1,408 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Digital Mars - The D Programming Language - std.regexp + + + + +www.digitalmars.com + +Home +| Search +| D +| Comments + +
    +Last update Mon Aug 22 2005 +


    + + + +
    +
    +
    + + + + + +
    +
    +
    D
    +
    Language
    +
    Phobos
    +
    Comparisons


    + +object
    +
    + +std
    std.base64
    std.boxer
    std.compiler
    std.conv
    std.ctype
    std.date
    std.file
    std.format
    std.gc
    std.intrinsic
    std.math
    std.md5
    std.mmfile
    std.openrj
    std.outbuffer
    std.path
    std.process
    std.random
    std.recls
    std.regexp
    std.socket
    std.socketstream
    std.stdint
    std.stdio
    std.cstream
    std.stream
    std.string
    std.system
    std.thread
    std.uri
    std.utf
    std.zip
    std.zlib
    +
    +std.windows
    +
    +std.linux
    +
    +std.c
    std.c.stdio
    +
    +std.c.windows
    +
    +std.c.linux
    +
    +
    +
    + + +

    std.regexp

    + + +Regular expressions +are a powerful method of string pattern matching. +The regular expression +language used is the same as that commonly used, however, some of the very +advanced forms may behave slightly differently. +

    + +

    + +
    int find(char[] string, char[] pattern, char[] attributes = null) +
    Search string for first match + with regular expression pattern with attributes. + Returns index of match if found, -1 if no match. +

    + +

    int rfind(char[] string, char[] pattern, char[] attributes = null) +
    Search string for last match with regular expression + pattern with attributes. + Returns index of match if found, -1 if no match. +

    + +

    RegExp search(char[] string, char[] pattern, char[] attributes = null) +
    Search string for first match + with regular expression pattern with attributes. + Returns corresponding RegExp if found, null if not. +

    + +

    char[] sub(char[] string, char[] pattern, char[] format, char[] attributes = null) +
    Search string for matches with regular expression + pattern with attributes. + Replace each match with string generated from format. + Return the resulting string. +

    + +

    char[] sub(char[] string, char[] pattern, char[] delegate(RegExp) dg, char[] attributes = null) +
    Search string for matches with regular expression + pattern with attributes. + Pass each match to delegate dg. + Replace each match with the return value from dg. + Return the resulting string. +

    + +

    char[][] split(char[] string, char[] pattern, char[] attributes = null) +
    Split string into an array of strings, + using the regular expression pattern with attributes + as the separator. + Returns array of slices into string. +

    + + +

    + +RegExp is a D class to handle regular expressions. +It is +the core foundation for adding powerful string pattern matching capabilities +to programs like grep, text editors, awk, sed, etc. +The RegExp class has these methods: + +
    +
    this(char[] pattern, char[] attributes) +
    Create a new RegExp object. Compile pattern + with attributes into + an internal form for fast execution. + Throws a RegExpError if there are any compilation errors. +

    + +

    char[][] split(char[] string) +
    Split string into an array of strings, + using the regular expression as the separator. + Returns array of slices in string. +

    + +

    int find(char[] string) +
    Search string for match with regular expression. + + + + + +
    Returns + Description +
    >=0 + index of match +
    -1 + no match +
    +

    + +

    char[][] match(char[] string) +
    Search string for match. + + + + + +
    Attribute + Returns +
    global + same as call to exec(string) +
    not global + array of all matches +
    +

    + +

    char[][] exec(char[] string) +
    Search string for next match. + Returns array of slices into string representing matches. +

    + +

    int test(char[] string) +
    Search string for next match. + + + + + +
    Returns + Description +
    0 + no match +
    !=0 + match +
    +

    + + +

    char[] replace(char[] string, char[] format) +
    Find regular expression matches in string. + Replace those matches + with a new string composed of format + merged with the result of the matches. + + + + + +
    Attribute + Action +
    global + replace all matches +
    not global + replace first match +
    + Returns the new string. +

    + +

    char[] replace(char[] format) +
    After a match is found with test(), this function + will take the match results and, using the format + string, generate and return a new string. +

    + +

    char[] replaceOld(char[] format) +
    Like replace(char[] format), but uses old style formatting: + + + + + + + + +
    Format + Description +
    & + replace with the match +
    \n + replace with the nth parenthesized match, n is 1..9 +
    \c + replace with char c. +
    +

    + + + +

    + +

    attributes

    + + attributes are a string controlling the interpretation + of the regulat expression. It consists of a sequence of one or more + of the following characters: +

    + + + + + + + + +
    Attribute + Action +
    g + global; repeat over the whole input string +
    i + case insensitive +
    m + treat as multiple lines separated by newlines +
    + +

    format

    + + format strings are a sequence of characters with embedded + format commands used to generate a new string from a regular + expression match. + The format commands are: +

    + + + + + + + + + + + + + + + + + + + + + + + + +
    Format + Description +
    $ + insert $ +
    $& + insert the matched substring +
    $` + insert the string that precedes the match +
    $' + insert the string that following the match +
    $n + replace with the nth parenthesized match, + n is 1..9 +
    $nn + replace with the nnth parenthesized match, + nn is 01..99 +
    $ + insert $ +
    + + +

    +

    Feedback and Comments

    + + Add feedback and comments regarding this + page. + +
    +Copyright © 1999-2005 by Digital Mars, All Rights Reserved

    + + + + + + + + + + + + diff -uNr dmd-0.129/dmd/html/d/phobos/std_socket.html dmd-0.130/dmd/html/d/phobos/std_socket.html --- dmd-0.129/dmd/html/d/phobos/std_socket.html 1970-01-01 01:00:00.000000000 +0100 +++ dmd-0.130/dmd/html/d/phobos/std_socket.html 2005-08-22 22:42:58.000000000 +0200 @@ -0,0 +1,687 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Digital Mars - The D Programming Language - std.socket + + + + +www.digitalmars.com + +Home +| Search +| D +| Comments + +
    +Last update Mon Aug 22 2005 +


    + + + +
    +
    +
    + + + + + +
    +
    +
    D
    +
    Language
    +
    Phobos
    +
    Comparisons


    + +object
    +
    + +std
    std.base64
    std.boxer
    std.compiler
    std.conv
    std.ctype
    std.date
    std.file
    std.format
    std.gc
    std.intrinsic
    std.math
    std.md5
    std.mmfile
    std.openrj
    std.outbuffer
    std.path
    std.process
    std.random
    std.recls
    std.regexp
    std.socket
    std.socketstream
    std.stdint
    std.stdio
    std.cstream
    std.stream
    std.string
    std.system
    std.thread
    std.uri
    std.utf
    std.zip
    std.zlib
    +
    +std.windows
    +
    +std.linux
    +
    +std.c
    std.c.stdio
    +
    +std.c.windows
    +
    +std.c.linux
    +
    +
    +
    + + +

    std.socket

    + + + +
    + +
    enum AddressFamily +
    The communication domain used to resolve an address: +

    +

    +
    UNIX +
    local communication +
    INET +
    internet protocol version 4 +
    INET6 +
    internet protocol version 6 +
    IPX +
    novell IPX +
    APPLETALK +
    appletalk +
    +

    + +

    enum SocketType +
    Communication semantics: +

    +

    +
    STREAM +
    sequenced, reliable, two-way communication-based byte streams +
    DGRAM +
    connectionless, unreliable datagrams with a fixed maximum length; + data may be lost or arrive out of order +
    RAW +
    raw protocol access +
    RDM +
    reliably-delivered message datagrams +
    SEQPACKET +
    sequenced, reliable, two-way connection-based datagrams with a fixed + maximum length +
    +

    + +

    enum ProtocolType +
    Protocol: +

    +

    +
    IP +
    internet protocol version 4 +
    IPV6 +
    internet protocol version 6 +
    ICMP +
    internet control message protocol +
    IGMP +
    internet group management protocol +
    GGP +
    gateway to gateway protocol +
    TCP +
    transmission control protocol +
    PUP +
    PARC universal packet protocol +
    UDP +
    user datagram protocol +
    IDP +
    Xerox NS protocol +
    +

    + +

    class Protocol +
    Protocol is a class for retrieving protocol information. +

    +

    +
    ProtocolType type +
    char[] name +
    char[][] aliases +
    These members are populated when one of the following + functions are called without failure: +

    + +

    bit getProtocolByName(char[] name) +
    bit getProtocolByType(ProtocolType type) +
    Returns false on failure. +

    +

    +

    + +

    class Service +
    Service is a class for retrieving service information. +

    +

    +
    char[] name +
    char[][] aliases +
    ushort port +
    char[] protocolName +
    These members are populated when one of the following + functions are called without failure: +

    + +

    bit getServiceByName(char[] name, char[] protocolName) +
    bit getServiceByName(char[] name) +
    bit getServiceByPort(ushort port, char[] protocolName) +
    bit getServiceByPort(ushort port) +
    If a protocol name is omitted, any protocol will be matched. + Returns false on failure. +

    +

    +

    + +


    +
    class AddressException : Exception +
    Base exception thrown from an Address. +

    + +

    abstract class Address +
    Address is an abstract class for representing a network addresses. +

    +

    +
    AddressFamily addressFamily() +
    Family of this address. +

    + +

    char[] toString() +
    Human readable string representing this address. +
    +

    + +

    class InternetAddress : Address +
    InternetAddress is a class that represents an IPv4 (internet protocol + version 4) address and port. +

    +

    +
    const uint ADDR_ANY +
    Any IPv4 address number. +
    const uint ADDR_NONE +
    An invalid IPv4 address number. +
    const ushort PORT_ANY +
    Any IPv4 port number. +

    + +

    this(uint addr, ushort port) +
    this(ushort port) +
    Construct a new Address. addr may be ADDR_ANY (default) and port + may be PORT_ANY, and the actual numbers may not be known + until a connection is made. +
    this(char[] addr, ushort port) +
    addr may be an IPv4 address string in the dotted-decimal form + a.b.c.d, or a host name that will be resolved using an + InternetHost object. port may be PORT_ANY as stated above. +

    + +

    AddressFamily addressFamily() +
    Overridden to return AddressFamily.INET. +
    ushort port() +
    Returns the IPv4 port number. +
    uint addr() +
    Returns the IPv4 address number. +

    + +

    char[] toAddrString() +
    Human readable string representing the IPv4 address in + dotted-decimal form. +
    char[] toPortString() +
    Human readable string representing the IPv4 port. +
    char[] toString() +
    Human readable string representing the IPv4 address and port + in the form a.b.c.d:e. +

    + +

    static uint parse(char[] addr) +
    Parse an IPv4 address string in the dotted-decimal form + a.b.c.d and return the number. If the string is not + a legitimate IPv4 address, ADDR_NONE is returned. +
    +

    + +


    +
    class HostException : Exception +
    Base exception thrown from an InternetHost. +

    +

    +
    int errorCode +
    Platform-specific error code. +
    +

    + +

    class InternetHost +
    InternetHost is a class for resolving IPv4 addresses. +

    +

    +
    char[] name +
    char[][] aliases +
    uint[] addrList +
    These members are populated when one of the following + functions are called without failure: +

    + +

    bit getHostByName(char[] name) +
    Resolve host name. Returns false if unable to resolve. +
    bit getHostByAddr(uint addr) +
    Resolve IPv4 address number. Returns false if unable to resolve. +
    bit getHostByAddr(char[] addr) +
    Same as previous, but addr is an IPv4 address string in the + dotted-decimal form a.b.c.d. Returns false if unable to resolve. +

    +

    +

    + +


    +
    enum SocketShutdown +
    How a socket is shutdown: +

    +

    +
    RECEIVE +
    socket receives are disallowed +
    SEND +
    socket sends are disallowed +
    BOTH +
    both RECEIVE and SEND +
    +

    + +

    enum SocketFlags +
    Flags may be OR'ed together: +

    +

    +
    NONE +
    no flags specified +
    OOB +
    out-of-band stream data +
    PEEK +
    peek at incoming data without removing it from the queue +
    DONTROUTE +
    data should not be subject to routing; + this flag may be ignored. +
    +

    + +

    enum SocketOptionLevel +
    The level at which a socket option is defined: +

    +

    +
    SOCKET +
    socket level +
    IP +
    internet protocol version 4 level +
    IPV6 +
    internet protocol version 6 level +
    TCP +
    transmission control protocol level +
    UDP +
    user datagram protocol level +
    +

    + +

    enum SocketOption +
    Specifies a socket option: +

    +

    +
    DEBUG +
    record debugging information +
    BROADCAST +
    allow transmission of broadcast messages +
    REUSEADDR +
    allow local reuse of address +
    LINGER +
    linger on close if unsent data is present +
    OOBINLINE +
    receive out-of-band data in band +
    SNDBUF +
    send buffer size +
    RCVBUF +
    receive buffer size +
    KEEPALIVE +
    keep connection alive +
    DONTROUTE +
    do not route +
    TCP_NODELAY +
    disable the Nagle algorithm for send coalescing +
    +

    + + +

    struct linger +
    Linger information for use with SocketOption.LINGER. +

    +

    +
    on +
    Nonzero for on. +
    time +
    Linger time. +
    +

    + +

    struct timeval +
    Duration timeout value. +

    +

    +
    seconds +
    Number of seconds. +
    microseconds +
    Number of additional microseconds. +
    +

    + +

    class SocketException : Exception +
    Base exception thrown from a Socket. +

    +

    +
    int errorCode +
    Platform-specific error code. +
    +

    + +

    class Socket +
    Socket is a class that creates a network communication endpoint + using the Berkeley sockets interface. +

    +

    +
    this(AddressFamily af, SocketType type, ProtocolType protocol) +
    this(AddressFamily af, SocketType type, char[] protocolName) +
    this(AddressFamily af, SocketType type) +
    Create a blocking socket. If a single protocol type exists to support this socket type + within the address family, the ProtocolType may be omitted. +

    + +

    static char[] hostName +
    Property to get the local machine's host name. +

    + +

    bit blocking +
    Property to get or set whether the socket is blocking or nonblocking. +

    + +

    bit isAlive +
    Property that indicates if this is a valid, alive socket. +

    + +

    AddressFamily addressFamily() +
    Get the socket's address family. +

    + +

    void bind(Address addr) +
    Associate a local address with this socket. +

    + +

    void connect(Address to) +
    Establish a connection. If the socket is blocking, connect waits for + the connection to be made. If the socket is nonblocking, connect returns + immediately and the connection attempt is still in progress. +

    + +

    void listen(int backlog) +
    Listen for an incoming connection. bind must be called before you + can listen. The backlog is a request of how many pending incoming + connections are queued until accept'ed. +

    + +

    Socket accept() +
    Accept an incoming connection. If the socket is blocking, accept + waits for a connection request. Throws SocketAcceptException if + unable to accept. See accepting for use with derived classes. +

    + +

    protected Socket accepting() +
    Called by accept when a new Socket must be created for a new connection. + To use a derived class, override this method and return an instance of your class. + The returned Socket's handle must not be set; Socket has a protected constructor + this() to use in this situation. +

    + +

    void shutdown(SocketShutdown how) +
    Disables sends and/or receives. +

    + +

    void close() +
    Immediately drop any connections and release socket resources. + Calling shutdown before close is recommended for + connection-oriented sockets. The Socket object is no longer + usable after close. +

    + +

    static char[] hostName +
    Property to get the local machine's host name. +

    + +

    Address remoteAddress() +
    Remote endpoint Address. +

    + +

    Address localAddress() +
    Local endpoint Address. +

    + +

    const int ERROR +
    Send or receive error code. +

    + +

    int send(void[] buf, SocketFlags flags) +
    int send(void[] buf) +
    Send data on the connection. Returns the number of bytes actually + sent, or ERROR on failure. If the socket is blocking and + there is no buffer space left, send waits. +

    + +

    int sendTo(void[] buf, SocketFlags flags, Address to) +
    int sendTo(void[] buf, Address to) +
    int sendTo(void[] buf, SocketFlags flags) +
    int sendTo(void[] buf) +
    Send data to a specific destination Address. + If the destination address is not specified, a connection must have + been made and that address is used. If the socket is blocking and + there is no buffer space left, sendTo waits. +

    + +

    int receive(void[] buf, SocketFlags flags) +
    int receive(void[] buf) +
    Receive data on the connection. Returns the number of bytes actually + received, 0 if the remote side has closed the connection, or ERROR + on failure. If the socket is blocking, receive waits until there + is data to be received. +

    + +

    int receiveFrom(void[] buf, SocketFlags flags, out Address from) +
    int receiveFrom(void[] buf, out Address from) +
    int receiveFrom(void[] buf, SocketFlags flags) +
    int receiveFrom(void[] buf) +
    Receive data and get the remote endpoint Address. Returns the number + of bytes actually received, 0 if the remote side has closed the connection, + or ERROR on failure. If the socket is blocking, receiveFrom + waits until there is data to be received. +

    + +

    int getOption(SocketOptionLevel level, SocketOption option, void[] result) +
    Get a socket option. Returns the number of bytes written to result. +
    int getOption(SocketOptionLevel level, SocketOption option, out int result) +
    Common case of getting integer and boolean options. +
    int getOption(SocketOptionLevel level, SocketOption option, out linger result) +
    Get the linger option. +

    + +

    void setOption(SocketOptionLevel level, SocketOption option, void[] value) +
    Set a socket option. +
    void setOption(SocketOptionLevel level, SocketOption option, int value) +
    Common case of setting integer and boolean options. +
    void setOption(SocketOptionLevel level, SocketOption option, linger value) +
    Set the linger option. +

    + +

    static int select(SocketSet checkRead, SocketSet checkWrite, SocketSet checkError, timeval* tv) +
    static int select(SocketSet checkRead, SocketSet checkWrite, SocketSet checkError, int microseconds) +
    static int select(SocketSet checkRead, SocketSet checkWrite, SocketSet checkError) +
    Wait for a socket to change status. A wait timeout timeval or + int microseconds may be specified; if a timeout is not specified or the + timeval is null, the maximum timeout is used. The timeval timeout + has an unspecified value when select returns. Returns the number + of sockets with status changes, 0 on timeout, or -1 on interruption. + If the return value is greater than 0, the SocketSets are updated + to only contain the sockets having status changes. + For a connecting socket, a write status change means the connection + is established and it's able to send. For a listening socket, + a read status change means there is an incoming connection request and + it's able to accept. +

    +

    + +
    class TcpSocket : Socket +
    TcpSocket is a shortcut class for a TCP Socket. +

    +

    +
    this() +
    this(AddressFamily family) +
    Constructs a blocking TCP Socket. +
    this(InternetAddress connectTo) +
    Constructs a blocking TCP Socket and connects to an InternetAddress. +

    +

    + +
    class UdpSocket : Socket +
    UdpSocket is a shortcut class for a UDP Socket. +

    +

    +
    this() +
    this(AddressFamily family) +
    Constructs a blocking UDP Socket. +

    +

    + +

    +
    class SocketSet +
    A collection of sockets for use with Socket.select. +

    +

    +
    this(uint max) +
    Set the maximum amount of sockets that may be added. +
    this() +
    Uses the default maximum for the system. +

    + +

    uint max +
    Property to get the maximum amount of sockets that may be added + to this SocketSet. +

    + +

    void add(Socket s) +
    Add a Socket to the collection. + Adding more than the maximum has dangerous side affects. +

    + +

    void remove(Socket s) +
    Remove this Socket from the collection. +

    + +

    int isSet(Socket s) +
    Returns nonzero if this Socket is in the collection. +

    + +

    void reset() +
    Reset the SocketSet so that there are 0 Sockets + in the collection. +

    +

    + +
    + +

    Notes

    + + For Win32 systems, link with ws2_32.lib. + +

    Example

    + + See /dmd/samples/d/listener.d. + +
    written by Christopher E. Miller + + +
    +

    Feedback and Comments

    + + Add feedback and comments regarding this + page. + +
    +Copyright © 1999-2005 by Digital Mars, All Rights Reserved

    + + + + + + + + + + + + + diff -uNr dmd-0.129/dmd/html/d/phobos/std_socketstream.html dmd-0.130/dmd/html/d/phobos/std_socketstream.html --- dmd-0.129/dmd/html/d/phobos/std_socketstream.html 1970-01-01 01:00:00.000000000 +0100 +++ dmd-0.130/dmd/html/d/phobos/std_socketstream.html 2005-08-22 22:42:58.000000000 +0200 @@ -0,0 +1,212 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Digital Mars - The D Programming Language - std.socketstream + + + + +www.digitalmars.com + +Home +| Search +| D +| Comments + +
    +Last update Mon Aug 22 2005 +


    + + + +
    +
    +
    + + + + + +
    +
    +
    D
    +
    Language
    +
    Phobos
    +
    Comparisons


    + +object
    +
    + +std
    std.base64
    std.boxer
    std.compiler
    std.conv
    std.ctype
    std.date
    std.file
    std.format
    std.gc
    std.intrinsic
    std.math
    std.md5
    std.mmfile
    std.openrj
    std.outbuffer
    std.path
    std.process
    std.random
    std.recls
    std.regexp
    std.socket
    std.socketstream
    std.stdint
    std.stdio
    std.cstream
    std.stream
    std.string
    std.system
    std.thread
    std.uri
    std.utf
    std.zip
    std.zlib
    +
    +std.windows
    +
    +std.linux
    +
    +std.c
    std.c.stdio
    +
    +std.c.windows
    +
    +std.c.linux
    +
    +
    +
    + + +

    std.socketstream

    + + +
    + +
    class SocketStream : std.stream.Stream +
    SocketStream is a stream for a blocking, + connected Socket. +

    +

    +
    this(Socket sock, std.stream.FileMode mode) +
    Constructs a SocketStream with the specified + Socket and FileMode flags. +
    this(Socket sock) +
    Uses mode FileMode.In | FileMode.Out. +

    + +

    Socket socket +
    Property to get the Socket that is being + streamed. +

    + +

    uint readBlock(void* buffer, uint size) +
    Attempts to read the entire block, waiting if necessary. +

    + +

    char[] readLine() +
    wchar[] readLineW() +
    Read a line. Safely does not use ungetc/ungetcw. +

    + +

    uint writeBlock(void* buffer, uint size) +
    Attempts to write the entire block, waiting if necessary. +

    + +

    bit eof() +
    Returns true if a remote disconnection has been detected. +

    + +

    char[] toString() +
    Does not return the entire stream because that would + require the remote connection to be closed. +

    + +

    void close() +
    Close the Socket. +

    +

    + +
    + + +

    Notes

    + + For Win32 systems, link with ws2_32.lib. + +

    Example

    + + See /dmd/samples/d/htmlget.d. + + +
    +

    Feedback and Comments

    + + Add feedback and comments regarding this + page. + +
    +Copyright © 1999-2005 by Digital Mars, All Rights Reserved

    + + + + + + + + + + + diff -uNr dmd-0.129/dmd/html/d/phobos/std_stdint.html dmd-0.130/dmd/html/d/phobos/std_stdint.html --- dmd-0.129/dmd/html/d/phobos/std_stdint.html 1970-01-01 01:00:00.000000000 +0100 +++ dmd-0.130/dmd/html/d/phobos/std_stdint.html 2005-08-22 22:42:58.000000000 +0200 @@ -0,0 +1,275 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Digital Mars - The D Programming Language - std.stdint + + + + +www.digitalmars.com + +Home +| Search +| D +| Comments + +
    +Last update Mon Aug 22 2005 +


    + + + +
    +
    +
    + + + + + +
    +
    +
    D
    +
    Language
    +
    Phobos
    +
    Comparisons


    + +object
    +
    + +std
    std.base64
    std.boxer
    std.compiler
    std.conv
    std.ctype
    std.date
    std.file
    std.format
    std.gc
    std.intrinsic
    std.math
    std.md5
    std.mmfile
    std.openrj
    std.outbuffer
    std.path
    std.process
    std.random
    std.recls
    std.regexp
    std.socket
    std.socketstream
    std.stdint
    std.stdio
    std.cstream
    std.stream
    std.string
    std.system
    std.thread
    std.uri
    std.utf
    std.zip
    std.zlib
    +
    +std.windows
    +
    +std.linux
    +
    +std.c
    std.c.stdio
    +
    +std.c.windows
    +
    +std.c.linux
    +
    +
    +
    + + +

    std.stdint

    + + + + D constrains integral types to specific sizes. But efficiency + of different sizes varies from machine to machine, + pointer sizes vary, and the maximum integer size varies. + stdint offers a portable way of trading off size + vs efficiency, in a manner compatible with the stdint.h + definitions in C. +

    + + The exact aliases are types of exactly the specified number of bits. + The at least aliases are at least the specified number of bits + large, and can be larger. + The fast aliases are the fastest integral type supported by the + processor that is at least as wide as the specified number of bits. +

    + + The aliases are: +

    + + + + + + + + + + +
    Exact Alias + Description + At Least Alias + Description + Fast Alias + Description +
    int8_t + exactly 8 bits signed + int_least8_t + at least 8 bits signed + int_fast8_t + fast 8 bits signed +
    uint8_t + exactly 8 bits unsigned + uint_least8_t + at least 8 bits unsigned + uint_fast8_t + fast 8 bits unsigned + +
    int16_t + exactly 16 bits signed + int_least16_t + at least 16 bits signed + int_fast16_t + fast 16 bits signed +
    uint16_t + exactly 16 bits unsigned + uint_least16_t + at least 16 bits unsigned + uint_fast16_t + fast 16 bits unsigned + +
    int32_t + exactly 32 bits signed + int_least32_t + at least 32 bits signed + int_fast32_t + fast 32 bits signed +
    uint32_t + exactly 32 bits unsigned + uint_least32_t + at least 32 bits unsigned + uint_fast32_t + fast 32 bits unsigned + +
    int64_t + exactly 64 bits signed + int_least64_t + at least 64 bits signed + int_fast64_t + fast 64 bits signed +
    uint64_t + exactly 64 bits unsigned + uint_least64_t + at least 64 bits unsigned + uint_fast64_t + fast 64 bits unsigned +
    +

    + + The ptr aliases are integral types guaranteed to be large enough + to hold a pointer without losing bits: +

    + + + + +
    Alias + Description +
    intptr_t + signed integral type large enough to hold a pointer +
    uintptr_t + unsigned integral type large enough to hold a pointer +
    +

    + + The max aliases are the largest integral types: +

    + + + + +
    Alias + Description +
    intmax_t + the largest signed integral type +
    uintmax_t + the largest unsigned integral type +
    + + +

    +

    Feedback and Comments

    + + Add feedback and comments regarding this + page. + +
    +Copyright © 1999-2005 by Digital Mars, All Rights Reserved

    + + + + + + + + + + + + + diff -uNr dmd-0.129/dmd/html/d/phobos/std_stdio.html dmd-0.130/dmd/html/d/phobos/std_stdio.html --- dmd-0.129/dmd/html/d/phobos/std_stdio.html 1970-01-01 01:00:00.000000000 +0100 +++ dmd-0.130/dmd/html/d/phobos/std_stdio.html 2005-08-22 22:42:58.000000000 +0200 @@ -0,0 +1,190 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Digital Mars - The D Programming Language - std.stdio + + + + +www.digitalmars.com + +Home +| Search +| D +| Comments + +
    +Last update Mon Aug 22 2005 +


    + + + +
    +
    +
    + + + + + +
    +
    +
    D
    +
    Language
    +
    Phobos
    +
    Comparisons


    + +object
    +
    + +std
    std.base64
    std.boxer
    std.compiler
    std.conv
    std.ctype
    std.date
    std.file
    std.format
    std.gc
    std.intrinsic
    std.math
    std.md5
    std.mmfile
    std.openrj
    std.outbuffer
    std.path
    std.process
    std.random
    std.recls
    std.regexp
    std.socket
    std.socketstream
    std.stdint
    std.stdio
    std.cstream
    std.stream
    std.string
    std.system
    std.thread
    std.uri
    std.utf
    std.zip
    std.zlib
    +
    +std.windows
    +
    +std.linux
    +
    +std.c
    std.c.stdio
    +
    +std.c.windows
    +
    +std.c.linux
    +
    +
    +
    + + +

    std.stdio

    + + + Standard I/O functions that extend std.c.stdio. + std.c.stdio is automatically imported when importing + std.stdio. + +
    +
    void writef(...); +
    Arguments are formatted per the + + format strings and written to stdout. +

    + +

    void writefln(...); +
    Same as writef, but a newline is appended + to the output. +

    + +

    void fwritef(FILE* fp, ...); +
    Same as writef, but output is sent to the + stream fp instead of stdout. +

    + +

    void fwritefln(FILE* fp, ...); +
    Same as writefln, but output is sent to the + stream fp instead of stdout. +

    + +

    void writefx(FILE* fp, TypeInfo[] arguments, void* argptr, int newline = false); +
    Same as writef, but output is sent to the + stream fp instead of stdout, the variadic inputs + are expanded to the arguments and argptr pair and + the newline is an optional parameter with no newline by default. +

    +

    + + +
    +

    Feedback and Comments

    + + Add feedback and comments regarding this + page. + +
    +Copyright © 1999-2005 by Digital Mars, All Rights Reserved

    + + + + + + + + + + + + diff -uNr dmd-0.129/dmd/html/d/phobos/std_stream.html dmd-0.130/dmd/html/d/phobos/std_stream.html --- dmd-0.129/dmd/html/d/phobos/std_stream.html 1970-01-01 01:00:00.000000000 +0100 +++ dmd-0.130/dmd/html/d/phobos/std_stream.html 2005-09-06 11:34:28.000000000 +0200 @@ -0,0 +1,818 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Digital Mars - The D Programming Language - std.stream + + + + +www.digitalmars.com + +Home +| Search +| D +| Comments + +
    +Last update Tue Sep 06 2005 +


    + + + +
    +
    +
    + + + + + +
    +
    +
    D
    +
    Language
    +
    Phobos
    +
    Comparisons


    + +object
    +
    + +std
    std.base64
    std.boxer
    std.compiler
    std.conv
    std.ctype
    std.date
    std.file
    std.format
    std.gc
    std.intrinsic
    std.math
    std.md5
    std.mmfile
    std.openrj
    std.outbuffer
    std.path
    std.process
    std.random
    std.recls
    std.regexp
    std.socket
    std.socketstream
    std.stdint
    std.stdio
    std.cstream
    std.stream
    std.string
    std.system
    std.thread
    std.uri
    std.utf
    std.zip
    std.zlib
    +
    +std.windows
    +
    +std.linux
    +
    +std.c
    std.c.stdio
    +
    +std.c.windows
    +
    +std.c.linux
    +
    +
    +
    + + +

    std.stream

    + + + + +
    +
    interface InputStream +
    InputStream is the interface for readable streams. +

    +

    + +
    void readExact(void* buffer, size_t size) +
    Read exactly size bytes into the buffer, throwing a + ReadException if it is not correct. +

    + +

    size_t read(ubyte[] buffer) +
    Read a block of data big enough to fill the given array and + return the actual number of bytes read. Unfilled bytes are not + modified. +

    + +

    void read(out byte x) +
    void read(out ubyte x) +
    void read(out short x) +
    void read(out ushort x) +
    void read(out int x) +
    void read(out uint x) +
    void read(out long x) +
    void read(out ulong x) +
    void read(out float x) +
    void read(out double x) +
    void read(out real x) +
    void read(out ifloat x) +
    void read(out idouble x) +
    void read(out ireal x) +
    void read(out cfloat x) +
    void read(out cdouble x) +
    void read(out creal x) +
    void read(out char x) +
    void read(out wchar x) +
    void read(out dchar x) +
    void read(out char[] s) +
    void read(out wchar[] s) +
    Read a basic type or counted string, throwing a + ReadException if it could not be read. Outside of + byte, ubyte, and char, the format is implementation-specific + and should not be used except as opposite actions to + write. +

    + +

    char[] readLine() +
    char[] readLine(char[] buffer) +
    wchar[] readLineW() +
    wchar[] readLineW(wchar[] buffer) +
    Read a line that is terminated with some combination + of carriage return and line feed or end-of-file. The + terminators are not included. The wchar version is + identical. The optional buffer parameter is + filled (possibly with appending characters) and a slice of + the result is returned. +

    + +

    int opApply(int delegate(inout char[] line) dg) +
    int opApply(int delegate(inout ulong n, inout char[] line) dg) +
    int opApply(int delegate(inout wchar[] line) dg) +
    int opApply(int delegate(inout ulong n, inout wchar[] line) dg) +
    Overload foreach statements to read the stream line by line and + call the supplied delegate with each line or with each line with line + number. The string passed in line may be reused between calls to the + delegate. Line numbering starts at 1. Breaking out of the foreach will + leave the stream position at the beginning of the next line to be read. + For example, to echo a file line-by-line with line numbers run +
    +	
    +	Stream file = new BufferedFile("sample.txt");
    +	foreach(ulong n, char[] line; file) {
    +	  stdout.writefln("line %d: %s",n,line);
    +	}
    +	file.close();
    +	
    +	
    +

    + +

    char[] readString(size_t length) +
    Read a string of the given length, throwing + ReadException if there was a problem. +

    + +

    wchar[] readStringW(size_t length) +
    Read a string of the given length, throwing + ReadException if there was a problem. The file + format is implementation-specific and should not be + used except as opposite actions to write. +

    + +

    char getc() +
    wchar getcw() +
    Read and return the next character in the stream. + This is the only method that will handle ungetc + properly. getcw's format is implementation-specific. + If EOF is reached then getc returns char.init and getcw returns + wchar.init. +

    + +

    char ungetc(char c) +
    wchar ungetcw(wchar c) +
    Push a character back onto the stream. They will + be returned in first-in last-out order from getc/getcw. +

    + +

    int readf(...) +
    int vreadf(TypeInfo[] arguments, va_list args) +
    Scan a string from the input using a similar form + to C's scanf and std.format. + An argument of type char[] is interpreted as a format string. All other + arguments must be pointer types. If a format string is not + present a default will be supplied + computed from the base type of the pointer type. + An argument of type char[]* is filled (possibly with appending + characters) and a slice of the result is assigned back into the + argument. + For example the following readf statements are equivalent +
    +	
    +	int x;
    +	double y;
    +	char[] s;
    +	file.readf(&x, " hello ", &y, &s);
    +	file.readf("%d hello %f %s", &x, &y, &s);
    +	file.readf("%d hello %f", &x, &y, "%s", &s);
    +	
    +	
    +

    + +

    size_t available() +
    Retrieve the nubmer of bytes available for immediate reading. +

    + +

    bool eof() +
    Return whether the current file position is the same as the + end of the file. This does not require actually reading past the + end, as with stdio. For non-seekable streams this + might only return true after attempting to read past the end. +

    + +

    bool isOpen() +
    Return true if the stream is currently open. +

    + +

    + +

    +
    interface OutputStream +
    OutputStream is the interface for writable streams. +

    +

    + +
    void writeExact(void* buffer, size_t size) +
    Write exactly size bytes from buffer, or throw + a WriteException if that could not be done. +

    + +

    size_t write(ubyte[] buffer) +
    Write as much of the buffer as possible, returning the + number of bytes written. +

    + +

    void write(byte x) +
    void write(ubyte x) +
    void write(short x) +
    void write(ushort x) +
    void write(int x) +
    void write(uint x) +
    void write(long x) +
    void write(ulong x) +
    void write(float x) +
    void write(double x) +
    void write(real x) +
    void write(ifloat x) +
    void write(idouble x) +
    void write(ireal x) +
    void write(cfloat x) +
    void write(cdouble x) +
    void write(creal x) +
    void write(char x) +
    void write(wchar x) +
    void write(dchar x) +
    void write(char[] s) +
    void write(wchar[] s) +
    Write a basic type or counted string. Outside of byte, ubyte, + and char, the format is implementation-specific and should only be + used in conjunction with read. +

    + +

    void writeLine(char[] s) +
    Write a line of text, appending the line with an + operating-system-specific line ending. +

    + +

    void writeLineW(wchar[] s) +
    Write a line of text, appending the line with an + operating-system-specific line ending. The format is + implementation-specific. +

    + +

    void writeString(char[] s) +
    Write a string of text, throwing WriteException if + it could not be fully written. +

    + +

    void writeStringW(wchar[] s) +
    Write a string of text, throwing WriteException if + it could not be fully written. The format is + implementation-dependent. +

    + +

    size_t printf(char[] format, ...) +
    size_t vprintf(char[] format, va_list args) +
    Print a formatted string into the stream using printf-style + syntax, returning the number of bytes written. +

    + +

    OutputStream writef(...) +
    OutputStream writefln(...) +
    OutputStream writefx(TypeInfo[] arguments, void* argptr, int newline = false) +
    Print a formatted string into the stream using writef-style + syntax. See std.format. Returns + self to chain with other stream commands like flush. +

    + +

    void flush() +
    Flush pending output if appropriate. +

    + +

    void close() +
    Close the stream, flushing output if appropriate. +

    + +

    bool isOpen() +
    Return true if the stream is currently open. +

    + +

    + +

    +
    class Stream : InputStream,OutputStream +
    Stream is the base abstract class from which the other + stream classes derive. Stream's byte order is the format + native to the computer. +

    +

    +
    bit readable +
    Indicates whether this stream can be read from. +

    + +

    bit writeable +
    Indicates whether this stream can be written to. +

    + +

    bit seekable +
    Indicates whether this stream can be seeked within. +

    + +

    protected bit isopen +
    Indicates whether this stream is open. +

    + +

    protected bit readEOF +
    Indicates whether this stream is at eof after the last + read attempt. +

    + +

    protected bit prevCr +
    For a non-seekable stream indicates that the last readLine + or readLineW ended on a '\r' character. +

    + +

    Reading

    +
    These methods require that the readable flag be set. + Problems with reading result in a ReadException being thrown. + Stream implements the InputStream interface in addition to the + following methods. +

    + +

    size_t readBlock(void* buffer, size_t size) +
    Read up to size bytes into the buffer and return the number + of bytes actually read. A return value of 0 indicates end-of-file. +

    + +

    Writing

    +
    These methods require that the writeable flag be set. + Problems with writing result in a WriteException being thrown. + Stream implements the OutputStream interface in addition to the + following methods. +

    + +

    size_t writeBlock(void* buffer, size_t size) +
    Write up to size bytes from buffer in the + stream, returning the actual number of bytes that were written. +

    + +

    void copyFrom(Stream s) +
    Copies all data from s into this stream. + This may throw ReadException or WriteException + on failure. This restores the file position + of s so that it is unchanged. + +
    void copyFrom(Stream s, size_t count) +
    Copy a specified number of bytes from the given stream + into this one. This may throw ReadException or + WriteException on failure. Unlike the previous form, + this doesn't restore the file position of s. + +

    Seeking

    +
    These methods require that the seekable flag be set. + Problems with seeking result in a SeekException being thrown. +

    + +

    ulong seek(long offset, SeekPos whence) +
    Change the current position of the stream. whence is + either SeekPos.Set, in which case the offset is an absolute + index from the beginning of the stream, SeekPos.Current, in + which case the offset is a delta from the current position, or + SeekPos.End, in which case the offset is a delta from the + end of the stream (negative or zero offsets only make sense in + that case). This returns the new file position. +

    + +

    ulong seekSet(long offset) +
    ulong seekCur(long offset) +
    ulong seekEnd(long offset) +
    Aliases for their normal seek counterparts. +

    + +

    ulong position() +
    void position(ulong pos) +
    Retrieve or set the file position, identical to calling + seek(0, SeekPos.Current) or + seek(pos, SeekPos.Set) respectively. +

    + +

    ulong size() +
    Retrieve the size of the stream in bytes. The stream must + be seekable or a SeekException is thrown. +

    + +

    char[] toString() +
    Read the entire stream and return it as a string. If the stream + is not seekable the contents from the current position to eof is + read and returned. +

    + +

    uint toHash() +
    Get a hash of the stream by reading each byte and using it in + a CRC-32 checksum. +

    +

    + +

    +
    class File : Stream +
    This subclass is for file system streams. +

    + +

    +
    this() +
    this(char[] filename, FileMode mode = FileMode.In) +
    Create the stream with no open file, an open file in read + mode, or an open file with explicit file mode. mode, + if given, is a combination of FileMode.In (indicating a file + that can be read) and FileMode.Out (indicating a file that can + be written). Opening a file for reading that doesn't exist + will error. Opening a file for writing that doesn't exist + will create the file. The FileMode.OutNew mode will + open the file for writing and reset the legnth to zero. The + FileMode.Append mode will open the file for writing and + move the file position to the end of the file. +

    + +

    void open(char[] filename, FileMode mode = FileMode.In) +
    Open a file for the stream, in an identical manner to the + constructors. If an error occurs an OpenException is thrown. +

    + +

    void create(char[] filename, FileMode mode = FileMode.OutNew) +
    Create a file for the stream. +

    + +

    void close() +
    Close the current file if it is open; otherwise it does + nothing. +

    + +

    size_t available() +
    For a seekable file returns the difference of the size + and position and otherwise returns 0. +

    + +

    size_t readBlock(void* buffer, size_t size) +
    size_t writeBlock(void* buffer, size_t size) +
    ulong seek(long offset, SeekPos rel) +
    Overrides of the Stream methods. +

    +

    + +

    +
    class StreamException : Exception +
    A base class for stream exceptions +
    +
    this(char[] msg) +
    Construct a StreamException with given error message +
    +
    class ReadException : StreamException +
    An exception for errors during reading +
    +
    this(char[] msg) +
    Construct a ReadException with given error message +
    +
    class WriteException : StreamException +
    An exception for errors during writing +
    +
    this(char[] msg) +
    Construct a WriteException with given error message +
    +
    class SeekException : StreamException +
    An exception for errors during seeking +
    +
    this(char[] msg) +
    Construct a SeekException with given error message +
    +
    class StreamFileException : StreamException +
    An exception for File errors +
    +
    this(char[] msg) +
    Construct a StreamFileException with given error message +
    +
    class OpenException : StreamFileException +
    An exception for errors during File.open +
    +
    this(char[] msg) +
    Construct a OpenException with given error message +
    + +

    +
    class FilterStream : Stream +
    A base class for streams that wrap a source stream + with additional functionality. The method implementations + forward read/write/seek calls to the source stream. + A FilterStream can change the position of + the source stream arbitrarily and may not keep the source stream + state in sync with the FilterStream, even upon flushing and closing + the FilterStream. + It is recommended to not make + any assumptions about the state of the source position and + read/write state after a FilterStream has acted upon it. + Specifc subclasses of FilterStream should document how they + modify the source stream and if any invariants hold true between the + source and filter. +

    + +

    +
    this(Stream source) +
    Create a FilterStream for the given source. +
    Stream source +
    Property for the source stream. Setting the source stream + closes this stream before attaching the new source. Attaching an + open stream reopens this stream and resets the stream state. +
    bit nestClose +
    Property indicating when this stream closes to close the + source stream as well. Defaults to true. +
    void resetSource() +
    Indicates the source stream changed state and that this + stream should reset any readable, writeable, seekable, isopen and + buffering flags. +
    void close() +
    size_t readBlock(void* buffer, size_t size) +
    size_t writeBlock(void* buffer, size_t size) +
    ulong seek(long offset, SeekPos rel) +
    size_t available() +
    void flush() +
    Overrides of the Stream methods. +
    + +

    +
    class BufferedStream : FilterStream +
    This subclass is for buffering a source stream. A buffered + stream must be closed explicitly to ensure the final buffer + content is written to the source stream. The source stream + position is changed according to the block size so reading or + writing to the BufferedStream may not change the source stream + position by the same amount. +

    + +

    +
    this(Stream source, uint bufferSize = 8192) +
    Create a buffered stream for the stream source with + the buffer size bufferSize. +
    + +

    +
    class BufferedFile : BufferedStream +
    This subclass is for buffered file system streams. It is + a convenience class for wrapping a File in a BufferedStream. + A buffered stream must be closed explicitly to ensure the final + buffer content is written to the file. +

    + +

    +
    this() +
    this(char[] filename, FileMode mode = FileMode.In, uint buffersize = 8192) +
    this(File file, uint buffersize = 8192) +
    void open(char[] filename, FileMode mode = FileMode.In) +
    void create(char[] filename, FileMode mode = FileMode.OutNew) +
    void close() +
    size_t readBlock(void* buffer, size_t size) +
    size_t writeBlock(void* buffer, size_t size) +
    ulong seek(long offset, SeekPos rel) +
    Overrides of the Stream methods. +

    +

    + +

    +
    enum BOM +
    UTF byte-order-mark signatures +
    +
    UTF8 +
    UTF-8 +
    UTF16LE +
    UTF-16 Little Endian +
    UTF16BE +
    UTF-16 Big Endian +
    UTF32LE +
    UTF-32 Little Endian +
    UTF32BE +
    UTF-32 Big Endian +
    +

    + +

    class EndianStream : FilterStream +
    This subclass wraps a stream with big-endian or + little-endian byte order swapping. UTF Byte-Order-Mark (BOM) + signatures can be read and deduced or written. Note that + an EndianStream should not be used as the source of another + FilterStream since a FilterStream call the source with + byte-oriented read/write requests and the EndianStream will not + perform any byte swapping. The EndianStream reads and writes + binary data (non-getc functions) in a one-to-one manner with + the source stream so the source stream's position and state + will be kept in sync with the EndianStream if only non-getc + functions are called. +

    +

    +
    this(Stream source, Endian end = std.system.endian) +
    Create the endian stream for the source stream + source with endianness end. The default + endianness is the native byte order. The Endian type is + defined in the std.system module. +
    Endian endian +
    property for endianness of the source stream +
    int readBOM(int ungetCharSize = 1) +
    Return -1 if no BOM and otherwise read the BOM and return it. + If there is no BOM or if bytes beyond the BOM are read + then the bytes read are pushed back onto the ungetc buffer or + ungetcw buffer. Pass ungetCharSize == 2 to use ungetcw instead + of ungetc when no BOM is present. +
    void writeBOM(BOM b) +
    Write the BOM b to the source stream +
    final void fixBO(void* buffer, size_t size) +
    fix the byte order of the given buffer to match the native order +
    final void fixBlockBO(void* buffer, uint size, size_t repeat) +
    fix the byte order of the given buffer in blocks of the given + size and repeated the given number of times +

    + +

    +

    +
    class TArrayStream(Buffer) : Stream +
    This subclass wraps an array-like buffer with a stream + interface. The type Buffer must support the length + property and reading ubyte slices. Compile in release mode + when directly instantiating a TArrayStream to avoid link errors. +

    +

    +
    this(Buffer buf) +
    Create the stream for the the buffer buf. +

    +

    ubyte[] data() +
    Get the current memory data in total. +

    +

    size_t readBlock(void* buffer, size_t size) +
    size_t writeBlock(void* buffer, size_t size) +
    ulong seek(long offset, SeekPos rel) +
    char[] toString() +
    size_t available() +
    Overrides of Stream methods. +

    + +

    + +

    +
    class MemoryStream : TArrayStream!(ubyte[]) +
    This subclass reads and constructs an array of bytes in + memory. +

    + +

    +
    this() +
    this(ubyte[] data) +
    Create the output buffer and setup for reading, writing, + and seeking. The second constructor loads it with specific + input data. +

    + +

    void reserve(size_t count) +
    Ensure the stream can hold count bytes. +

    + +

    size_t writeBlock(void* buffer, size_t size) +
    Overrides of Stream methods. +

    +

    + +

    +
    class MmFileStream : TArrayStream!(MmFile) +
    This subclass wraps a memory-mapped file with the stream API. + See std.mmfile module. +

    + +

    +
    this(MmFile file) +
    Create stream wrapper for file. +

    +

    void flush() +
    void close() +
    Overrides of Stream methods to forward to MmFile. Note + close deletes the MmFile. +
    + +

    +
    class SliceStream : FilterStream +
    This subclass slices off a portion of another stream, making + seeking relative to the boundaries of the slice. It could be + used to section a large file into a set of smaller files, such as + with tar archives. Reading and writing a SliceStream does not + modify the position of the source stream if it is seekable. +

    + +

    +
    this(Stream source, int low) +
    Indicate both the source stream to use for reading from and the + low part of the slice. The high part of the slice is dependent + upon the end of the source stream, so that if you write beyond the + end it resizes the stream normally. +

    + +

    this(Stream source, int low, int high) +
    Indicate the high index as well. Attempting to read or write + past the high index results in the end being clipped off. +

    + +

    size_t readBlock(void* buffer, size_t size) +
    size_t writeBlock(void* buffer, size_t size) +
    ulong seek(long offset, SeekPos rel) +
    size_t available() +
    Overrides of Stream methods. + +
    + + +
    +

    Feedback and Comments

    + + Add feedback and comments regarding this + page. + +
    +Copyright © 1999-2005 by Digital Mars, All Rights Reserved

    + + + + + + + + + diff -uNr dmd-0.129/dmd/html/d/phobos/std_string.html dmd-0.130/dmd/html/d/phobos/std_string.html --- dmd-0.129/dmd/html/d/phobos/std_string.html 1970-01-01 01:00:00.000000000 +0100 +++ dmd-0.130/dmd/html/d/phobos/std_string.html 2005-08-22 22:42:58.000000000 +0200 @@ -0,0 +1,524 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Digital Mars - The D Programming Language - std.string + + + + +www.digitalmars.com + +Home +| Search +| D +| Comments + +
    +Last update Mon Aug 22 2005 +


    + + + +
    +
    +
    + + + + + +
    +
    +
    D
    +
    Language
    +
    Phobos
    +
    Comparisons


    + +object
    +
    + +std
    std.base64
    std.boxer
    std.compiler
    std.conv
    std.ctype
    std.date
    std.file
    std.format
    std.gc
    std.intrinsic
    std.math
    std.md5
    std.mmfile
    std.openrj
    std.outbuffer
    std.path
    std.process
    std.random
    std.recls
    std.regexp
    std.socket
    std.socketstream
    std.stdint
    std.stdio
    std.cstream
    std.stream
    std.string
    std.system
    std.thread
    std.uri
    std.utf
    std.zip
    std.zlib
    +
    +std.windows
    +
    +std.linux
    +
    +std.c
    std.c.stdio
    +
    +std.c.windows
    +
    +std.c.linux
    +
    +
    +
    + + +

    std.string

    + + + +

    To copy or not to copy?

    + + When a function takes a string as a parameter, and returns a string, + is that string the same as the input string, modified in place, or + is it a modified copy of the input string? The D array convention is + "copy-on-write". This means that if no modifications are done, the + original string (or slices of it) can be returned. If any modifications + are done, the returned string is a copy. +

    + +

    + +
    class StringException +
    Thrown on errors in string functions. +

    + +

    const char[] hexdigits; +
    "0123456789ABCDEF" +

    + +

    const char[] digits; +
    "0123456789" +

    + +

    const char[] octdigits; +
    "01234567" +

    + +

    const char[] lowercase; +
    "abcdefghijklmnopqrstuvwxyz" +

    + +

    const char[] uppercase; +
    "ABCDEFGHIJKLMNOPQRSTUVWXYZ" +

    + +

    const char[] letters; +
    "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" +

    + +

    const char[] whitespace; +
    " \t\v\r\n\f" +

    + +

    long atoi(char[] s) +
    Convert string to integer. +

    + +

    real atof(char[] s) +
    Convert string to real. +

    + +

    int cmp(char[] s1, char[] s2) +
    Compare two strings. + Returns: +
    +
    <0 for (s1 < s2) +
    =0 for (s1 == s2) +
    >0 for (s1 > s2) +
    +

    + + +

    int icmp(char[] s1, char[] s2) +
    Same as cmp() but case insensitive. +

    + +

    char* toStringz(char[] s) +
    Converts a D array of chars to a C-style 0 terminated string. +

    + + +

    int find(char[] s, dchar c) +
    Find first occurrance of c in string s. + Return index in s where it is found. + Return -1 if not found. +

    + +

    int rfind(char[] s, dchar c) +
    Find last occurrance of c in string s. + Return index in s where it is found. + Return -1 if not found. +

    + +

    int find(char[] s, char[] sub) +
    Find first occurrance of sub in string s. + Return index in s[] where it is found. + Return -1 if not found. +

    + +

    int rfind(char[] s, char[] sub) +
    Find last occurrance of sub in string s. + Return index in s where it is found. + Return -1 if not found. +

    + +

    int ifind(char[] s, dchar c) +
    int irfind(char[] s, dchar c) +
    int ifind(char[] s, char[] sub) +
    int irfind(char[] s, char[] sub) +
    Case insensitive versions. +

    + +

    char[] tolower(char[] s) +
    Convert string to lower case. +

    + +

    char[] toupper(char[] s) +
    Convert string to upper case. +

    + +

    char[] capitalize(char[] s) +
    Capitalize first character of string. +

    + +

    char[] capwords(char[] s) +
    Capitalize all words in string. + Remove leading and trailing whitespace. + Replace all sequences of whitespace with a single space. +

    + +

    char[] join(char[][] words, char[] sep) +
    Concatenate all the strings together into one + string; use sep[] as the separator. +

    + +

    char[][] split(char[] s) +
    Split s[] into an array of words, + using whitespace as the delimiter. +

    + +

    char[][] split(char[] s, char[] delim) +
    Split s[] into an array of words, + using delim[] as the delimiter. +

    + +

    char[][] splitlines(char[] s) +
    Split s[] into an array of lines, + using CR, LF, or CR-LF as the delimiter. +

    + +

    char[] stripl(char[] s) +
    char[] stripr(char[] s) +
    char[] strip(char[] s) +
    Strips leading or trailing whitespace, or both. +

    + +

    char[] chomp(char[] s, char[] delimiter = null) +
    Returns s sans trailing delimiter, if any. + If delimiter is null, any trailing CR, LF, or CRLF + is removed. +

    + +

    char[] chop(char[] s) +
    Returns s sans trailing character, if there is one. + If last two characters are CR-LF, then both are removed. +

    + +

    char[] ljustify(char[] s, int width) +
    char[] rjustify(char[] s, int width) +
    char[] center(char[] s, int width) +
    Left justify, right justify, or center string s + in field width chars wide. +

    + +

    char[] zfill(char[] s, int width) +
    Same as rjustify(), but fill with '0's. +

    + +

    char[] replace(char[] s, char[] from, char[] to) +
    Replace occurrences of from with to in s. +

    + +

    char[] replaceSlice(char[] s, char[] slice, char[] replacement) +
    Given a string s with a slice into it, + replace slice[] with replacement. +

    + +

    char[] insert(char[] s, int index, char[] sub) +
    Insert sub into s at location index. +

    + +

    int count(char[] s, char[] sub) +
    Count up all instances of sub in s. +

    + +

    char[] expandtabs(char[] s, int tabsize) +
    Replace tabs with the appropriate number of spaces. + tabsize is the distance between tab stops. +

    + +

    char[] maketrans(char[] from, char[] to) +
    Construct translation table for translate(). +

    + +

    char[] translate(char[] s, char[] transtab, char[] delchars) +
    Translate characters in s using table created by maketrans(). + Delete chars in delchars. + Note: This only works if s is ASCII. + Use tr for full UCS character support. +

    + +

    char[] toString(bit arg) +
    char[] toString(char arg) +
    char[] toString(byte arg) +
    char[] toString(ubyte arg) +
    char[] toString(short arg) +
    char[] toString(ushort arg) +
    char[] toString(int arg) +
    char[] toString(uint arg) +
    char[] toString(long arg) +
    char[] toString(ulong arg) +
    char[] toString(float arg) +
    char[] toString(double arg) +
    char[] toString(real arg) +
    char[] toString(ifloat arg) +
    char[] toString(idouble arg) +
    char[] toString(ireal arg) +
    char[] toString(cfloat arg) +
    char[] toString(cdouble arg) +
    char[] toString(creal arg) +
    Convert arg to string. +

    + +

    char[] toString(long arg, uint radix) +
    Convert arg to string in radix radix. + radix must be a value from 2 to 36. + arg is treated as a signed value only if radix is 10. + The characters A through Z are used to represent values 10 through + 36. +

    + +

    char[] toString(ulong arg, uint radix) +
    Convert arg to string in radix radix. + radix must be a value from 2 to 36. + The characters A through Z are used to represent values 10 through + 36. +

    + +

    char[] toString(char* s) +
    Convert C-style 0 terminated string s to char[] string. +

    + +

    char[] format(...) +
    Format arguments into a string. +

    + +

    char[] sformat(char[] s, ...) +
    Format arguments into string s which must be large + enough to hold the result. Throws ArrayBoundsError if it is not. + Returns s. +

    + +

    char[] succ(char[] s) +
    Return string that is the 'successor' to s. + If the rightmost character is a-zA-Z0-9, it is incremented within + its case or digits. If it generates a carry, the process is + repeated with the one to its immediate left. +
    +	succ(null);	// returns null	
    +	succ("!@#$%");	// returns "!@#$%"
    +	succ("1");	// returns "2"
    +	succ("9");	// returns "10"
    +	succ("999");	// returns "1000"
    +	succ("zz99");	// returns "aaa00"
    +

    + + +

    char[] tr(char[] str, char[] from, char[] to, char[] modifiers = null) +
    Replaces characters in str that are in from + with corresponding characters in to and returns the resulting + string. +

    + + modifiers is a string of modifier characters: +

    + + + + + + + + +
    Modifier + Description +
    c + Complement the list of characters in from +
    d + Removes matching characters with no corresponding + replacement in to +
    s + Removes adjacent duplicates in the replaced characters +
    +

    + + If modifier d is present, then the number of characters + in to may be only 0 or 1. +

    + + If modifier d is not present and to is null, + then to is taken to be the same as from. +

    + + If modifier d is not present and to is shorter + than from, then to is extended by replicating the + last character in to. +

    + + Both from and to may contain ranges using the - + character, for example a-d is synonymous with abcd. + Neither accept a leading ^ as meaning the complement of + the string (use the c modifier for that). +

    + +

    + +

    Patterns

    + + A pattern is an array of characters much like a character + class in regular expressions. A sequence of characters + can be given, such as "abcde". The '-' can represent a range + of characters, as "a-e" represents the same pattern as "abcde". + "a-fA-F0-9" represents all the hex characters. + If the first character of a pattern is '^', then the pattern + is negated, i.e. "^0-9" means any character except a digit. + The following functions use patterns. +

    + + Note: In the future, the pattern syntax may be improved + to be more like regular expression character classes. + +

    + +
    int inPattern(dchar c, char[] pattern) +
    Returns 1 if c is in pattern, 0 if not. +

    + +

    int inPatterns(dchar c, char[][] patterns) +
    Returns 1 if c is in each of the patterns + in patterns, 0 if not. +

    + +

    size_t countchars(char[] s, char[] pattern) +
    Returns number of characters in s that match + pattern. +

    + +

    char[] removechars(char[] s, char[] pattern) +
    Return a string consisting of s with all the characters + that match pattern removed. +

    + +

    char[] squeeze(char[] s, char[] pattern = null) +
    Return a string consisting of s with all the + multiple sequences of characters + that match pattern are removed. + If pattern is null, it defaults to all characters. +
    +	squeeze("hello goodbye")	// returns "helo godbye"
    +	squeeze("hello goodbye", "le")	// returns "helo goodbye"
    +

    + + +

    + + +
    +

    Feedback and Comments

    + + Add feedback and comments regarding this + page. + +
    +Copyright © 1999-2005 by Digital Mars, All Rights Reserved

    + + + + + + + + + + + + + diff -uNr dmd-0.129/dmd/html/d/phobos/std_system.html dmd-0.130/dmd/html/d/phobos/std_system.html --- dmd-0.129/dmd/html/d/phobos/std_system.html 1970-01-01 01:00:00.000000000 +0100 +++ dmd-0.130/dmd/html/d/phobos/std_system.html 2005-08-22 22:42:58.000000000 +0200 @@ -0,0 +1,173 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Digital Mars - The D Programming Language - std.system + + + + +www.digitalmars.com + +Home +| Search +| D +| Comments + +
    +Last update Mon Aug 22 2005 +


    + + + +
    +
    +
    + + + + + +
    +
    +
    D
    +
    Language
    +
    Phobos
    +
    Comparisons


    + +object
    +
    + +std
    std.base64
    std.boxer
    std.compiler
    std.conv
    std.ctype
    std.date
    std.file
    std.format
    std.gc
    std.intrinsic
    std.math
    std.md5
    std.mmfile
    std.openrj
    std.outbuffer
    std.path
    std.process
    std.random
    std.recls
    std.regexp
    std.socket
    std.socketstream
    std.stdint
    std.stdio
    std.cstream
    std.stream
    std.string
    std.system
    std.thread
    std.uri
    std.utf
    std.zip
    std.zlib
    +
    +std.windows
    +
    +std.linux
    +
    +std.c
    std.c.stdio
    +
    +std.c.windows
    +
    +std.c.linux
    +
    +
    +
    + + +

    std.system

    + + +
    + +
    enum Endian +
    Byte order endianness +
    +
    BigEndian +
    big endian byte order +
    LittleEndian +
    little endian byte order +
    +

    +

    Endian endian +
    Native system endianness + +
    + + +
    +

    Feedback and Comments

    + + Add feedback and comments regarding this + page. + +
    +Copyright © 1999-2005 by Digital Mars, All Rights Reserved

    + + + + + + + + + + + + + diff -uNr dmd-0.129/dmd/html/d/phobos/std_thread.html dmd-0.130/dmd/html/d/phobos/std_thread.html --- dmd-0.129/dmd/html/d/phobos/std_thread.html 1970-01-01 01:00:00.000000000 +0100 +++ dmd-0.130/dmd/html/d/phobos/std_thread.html 2005-08-22 22:42:58.000000000 +0200 @@ -0,0 +1,303 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Digital Mars - The D Programming Language - std.thread + + + + +www.digitalmars.com + +Home +| Search +| D +| Comments + +
    +Last update Mon Aug 22 2005 +


    + + + +
    +
    +
    + + + + + +
    +
    +
    D
    +
    Language
    +
    Phobos
    +
    Comparisons


    + +object
    +
    + +std
    std.base64
    std.boxer
    std.compiler
    std.conv
    std.ctype
    std.date
    std.file
    std.format
    std.gc
    std.intrinsic
    std.math
    std.md5
    std.mmfile
    std.openrj
    std.outbuffer
    std.path
    std.process
    std.random
    std.recls
    std.regexp
    std.socket
    std.socketstream
    std.stdint
    std.stdio
    std.cstream
    std.stream
    std.string
    std.system
    std.thread
    std.uri
    std.utf
    std.zip
    std.zlib
    +
    +std.windows
    +
    +std.linux
    +
    +std.c
    std.c.stdio
    +
    +std.c.windows
    +
    +std.c.linux
    +
    +
    +
    + + +

    std.thread

    + + The thread module defines the class Thread. + Thread is the basis + for writing multithreaded applications. Each thread + has a unique instance of class Thread associated with it. + It is important to use the Thread class to create and manage + threads as the garbage collector needs to know about all the threads. +

    + +

    +
    typedef ... thread_hdl +
    The type of the thread handle used by the operating system. +

    + +

    class Thread +
    One for each thread. +

    + +

    class ThreadError +
    Thrown for errors. +

    +

    + + The members of Thread are: +

    + +

    + +
    this() +
    Constructor used by classes derived from Thread that + override main(). +

    + +

    this(int (*fp)(void*), void* arg) +
    Constructor used by classes derived from Thread that + override run(). +

    + +

    this(int delegate() dg) +
    Constructor used by classes derived from Thread that + override run(). +

    + +

    thread_hdl hdl; +
    The handle to this thread assigned by the operating system. + This is set to thread_id.init if the thread hasn't been started + yet. +

    + +

    void start(); +
    Create a new thread and start it running. The new thread + initializes itself and then calls run(). + start() can only be called once. +

    + +

    int run(void* p); +
    Entry point for a thread. If not overridden, it calls the + function pointer fp and argument arg passed in + the constructor, or the delegate dg. The return value + is the thread exit code, which is normally 0. +

    + +

    void wait(); +
    Wait for this thread to terminate. + Throws ThreadError + if the thread hasn't begun yet or has already terminated or + is called on itself. +

    + +

    void wait(unsigned milliseconds); +
    Wait for this thread to terminate or until milliseconds time has + elapsed, whichever occurs first. + Throws ThreadError + if the thread hasn't begun yet or has already terminated or + is called on itself. +

    + +

    TS getState(); +
    Returns the state of the thread. + The state is one of the following: +

    + + + + + + +
    TS + Description +
    INITIAL + The thread hasn't been started yet. +
    RUNNING + The thread is running or paused. +
    TERMINATED + The thread has ended. +
    +

    + +

    void setPriority(PRIORITY* p); +
    Adjust the priority of this thread. +

    + + + + + + +
    PRIORITY + Description +
    INCREASE + Increase thread priority +
    DECREASE + Decrease thread priority +
    IDLE + Assign thread low priority +
    CRITICAL + Assign thread high priority +
    +

    + +

    static Thread getThis(); +
    Returns a reference to the Thread for the thread + that called the function. +

    + +

    static Thread[] getAll(); +
    Returns an array of all the threads currently running. +

    + +

    void pause(); +
    Suspend execution of this thread. +

    + +

    void resume(); +
    Resume execution of this thread. +

    + +

    static void pauseAll(); +
    Suspend execution of all threads but this thread. +

    + +

    static void resumeAll(); +
    Resume execution of all paused threads. +

    + +

    static void yield(); +
    Give up the remainder of this thread's time slice. +

    + +

    + +
    +

    Feedback and Comments

    + + Add feedback and comments regarding this + page. + +
    +Copyright © 1999-2005 by Digital Mars, All Rights Reserved

    + + + + + + + + + + + diff -uNr dmd-0.129/dmd/html/d/phobos/std_uri.html dmd-0.130/dmd/html/d/phobos/std_uri.html --- dmd-0.129/dmd/html/d/phobos/std_uri.html 1970-01-01 01:00:00.000000000 +0100 +++ dmd-0.130/dmd/html/d/phobos/std_uri.html 2005-08-22 22:42:58.000000000 +0200 @@ -0,0 +1,188 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Digital Mars - The D Programming Language - std.uri + + + + +www.digitalmars.com + +Home +| Search +| D +| Comments + +
    +Last update Mon Aug 22 2005 +


    + + + +
    +
    +
    + + + + + +
    +
    +
    D
    +
    Language
    +
    Phobos
    +
    Comparisons


    + +object
    +
    + +std
    std.base64
    std.boxer
    std.compiler
    std.conv
    std.ctype
    std.date
    std.file
    std.format
    std.gc
    std.intrinsic
    std.math
    std.md5
    std.mmfile
    std.openrj
    std.outbuffer
    std.path
    std.process
    std.random
    std.recls
    std.regexp
    std.socket
    std.socketstream
    std.stdint
    std.stdio
    std.cstream
    std.stream
    std.string
    std.system
    std.thread
    std.uri
    std.utf
    std.zip
    std.zlib
    +
    +std.windows
    +
    +std.linux
    +
    +std.c
    std.c.stdio
    +
    +std.c.windows
    +
    +std.c.linux
    +
    +
    +
    + + +

    std.uri

    + + Encode and decode Uniform Resource Identifiers (URIs). + URIs are used in internet transfer protocols. + Valid URI characters consist of letters, digits, and + the characters ;/?:@&=+$,-_.!~*'(). Escape sequences + consist of '%' followed by two hex digits. + +
    +
    char[] decode(char[] encodedURI) +
    Decodes the URI string encodedURI into a UTF-8 string + and returns it. Escape sequences that resolve to valid URI + characters are not replaced. Escape sequences that resolve + to the '#' character are not replaced. +

    + +

    char[] decodeComponent(char[] encodedURIComponent) +
    Decodes the URI string encodedURI into a UTF-8 string + and returns it. All escape sequences are decoded. +

    + +

    char[] encode(char[] uri) +
    Encodes the UTF-8 string uri into a URI and returns + that URI. Any character not a valid URI character is escaped. + The '#' character is not escaped. +

    + +

    char[] encodeComponent(char[] uriComponent) +
    Encodes the UTF-8 string uri into a URI and returns + that URI. Any character not a letter, digit, or one of + -_.!~*'() is escaped. + +
    + + +
    +

    Feedback and Comments

    + + Add feedback and comments regarding this + page. + +
    +Copyright © 1999-2005 by Digital Mars, All Rights Reserved

    + + + + + + + + + + + + + diff -uNr dmd-0.129/dmd/html/d/phobos/std_utf.html dmd-0.130/dmd/html/d/phobos/std_utf.html --- dmd-0.129/dmd/html/d/phobos/std_utf.html 1970-01-01 01:00:00.000000000 +0100 +++ dmd-0.130/dmd/html/d/phobos/std_utf.html 2005-08-22 22:42:58.000000000 +0200 @@ -0,0 +1,231 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Digital Mars - The D Programming Language - std.utf + + + + +www.digitalmars.com + +Home +| Search +| D +| Comments + +
    +Last update Mon Aug 22 2005 +


    + + + +
    +
    +
    + + + + + +
    +
    +
    D
    +
    Language
    +
    Phobos
    +
    Comparisons


    + +object
    +
    + +std
    std.base64
    std.boxer
    std.compiler
    std.conv
    std.ctype
    std.date
    std.file
    std.format
    std.gc
    std.intrinsic
    std.math
    std.md5
    std.mmfile
    std.openrj
    std.outbuffer
    std.path
    std.process
    std.random
    std.recls
    std.regexp
    std.socket
    std.socketstream
    std.stdint
    std.stdio
    std.cstream
    std.stream
    std.string
    std.system
    std.thread
    std.uri
    std.utf
    std.zip
    std.zlib
    +
    +std.windows
    +
    +std.linux
    +
    +std.c
    std.c.stdio
    +
    +std.c.windows
    +
    +std.c.linux
    +
    +
    +
    + + +

    std.utf

    + + Encode and decode UTF-8, UTF-16 and UTF-32 strings. + For more information on UTF-8, see + http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8. +

    + + Note: For Win32 systems, the C wchar_t type + is UTF-16 and corresponds to the D wchar type. + For linux systems, the C wchar_t type + is UTF-32 and corresponds to the D utf.dchar type. +

    + + UTF character support is restricted to (0 <= character <= 0x10FFFF). + +

    +
    class UtfError +
    Exception class that is thrown upon any errors. + The members are: +
    +
    idx +
    Set to the index of the start of the offending UTF sequence. +
    +

    + +

    alias ... dchar +
    An alias for a single UTF-32 character. This may + become a D basic type in the future. +

    + +

    bit isValidDchar(dchar c) +
    Test if c is a valid UTF-32 character. + Returns true if it is, false if not. +

    + +

    dchar decode(char[] s, inout uint idx) +
    dchar decode(wchar[] s, inout uint idx) +
    dchar decode(dchar[] s, inout uint idx) +
    Decodes and returns character starting at s[idx]. + idx is advanced past the decoded character. + If the character is not well formed, a UriError + is thrown and idx remains unchanged. +

    + +

    void encode(inout char[] s, dchar c) +
    void encode(inout wchar[] s, dchar c) +
    void encode(inout dchar[] s, dchar c) +
    Encodes character c and appends it to array s. +

    + +

    void validate(char[] s) +
    void validate(wchar[] s) +
    void validate(dchar[] s) +
    Checks to see if string is well formed or not. + Throws a UtfError if it is not. + Use to check all untrusted input for correctness. +

    + +

    char[] toUTF8(char[] s) +
    char[] toUTF8(wchar[] s) +
    char[] toUTF8(dchar[] s) +
    Encodes string s into UTF-8 and returns the encoded string. +

    + +

    wchar[] toUTF16(char[] s) +
    wchar* toUTF16z(char[] s) +
    wchar[] toUTF16(wchar[] s) +
    wchar[] toUTF16(dchar[] s) +
    Encodes string s into UTF-16 and returns the encoded string. + toUTF16z is suitable for calling the 'W' functions in the + Win32 API that take an LPWSTR or LPCWSTR argument. +

    + +

    dchar[] toUTF32(char[] s) +
    dchar[] toUTF32(wchar[] s) +
    dchar[] toUTF32(dchar[] s) +
    Encodes string s into UTF-32 and returns the encoded string. + +
    + + +
    +

    Feedback and Comments

    + + Add feedback and comments regarding this + page. + +
    +Copyright © 1999-2005 by Digital Mars, All Rights Reserved

    + + + + + + + + + + diff -uNr dmd-0.129/dmd/html/d/phobos/std_zip.html dmd-0.130/dmd/html/d/phobos/std_zip.html --- dmd-0.129/dmd/html/d/phobos/std_zip.html 1970-01-01 01:00:00.000000000 +0100 +++ dmd-0.130/dmd/html/d/phobos/std_zip.html 2005-08-22 22:42:58.000000000 +0200 @@ -0,0 +1,351 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Digital Mars - The D Programming Language - std.zip + + + + +www.digitalmars.com + +Home +| Search +| D +| Comments + +
    +Last update Mon Aug 22 2005 +


    + + + +
    +
    +
    + + + + + +
    +
    +
    D
    +
    Language
    +
    Phobos
    +
    Comparisons


    + +object
    +
    + +std
    std.base64
    std.boxer
    std.compiler
    std.conv
    std.ctype
    std.date
    std.file
    std.format
    std.gc
    std.intrinsic
    std.math
    std.md5
    std.mmfile
    std.openrj
    std.outbuffer
    std.path
    std.process
    std.random
    std.recls
    std.regexp
    std.socket
    std.socketstream
    std.stdint
    std.stdio
    std.cstream
    std.stream
    std.string
    std.system
    std.thread
    std.uri
    std.utf
    std.zip
    std.zlib
    +
    +std.windows
    +
    +std.linux
    +
    +std.c
    std.c.stdio
    +
    +std.c.windows
    +
    +std.c.linux
    +
    +
    +
    + + +

    std.zip

    + + Read/write data in the zip archive format. + Makes use of the zlib compression library. + +
    + +
    class ZipException +
    Thrown on error. +

    + +

    class ZipArchive +
    Object representing the entire archive. + ZipArchives are collections of ArchiveMembers. +

    + +

    +
    this() +
    Constructor used when creating a new archive. +

    + +

    void addMember(ArchiveMember de) +
    Add de to the archive. +

    + +

    void deleteMember(ArchiveMember de) +
    Delete de from the archive. +

    + +

    void[] build() +
    Construct an archive out of the current members + of the archive. + Fills in the properties data[], diskNumber, diskStartDir, + numEntries, totalEntries, and directory[]. + For each ArchiveMember, fills in properties + crc32, + compressedSize, compressedData[]. + Return array representing the entire archive. +

    + +

    this(void[] data) +
    Constructor used when reading an existing archive. + data[] is the entire contents of the archive. + Fills in the properties data[], diskNumber, diskStartDir, + numEntries, totalEntries, comment[], and directory[]. + For each ArchiveMember, fills in properties + madeVersion, extractVersion, flags, + compressionMethod, time, + crc32, + compressedSize, + expandedSize, + compressedData[], + diskNumber, + internalAttributes, + externalAttributes, + name[], extra[], comment[]. + Use expand() to get the expanded data for each + ArchiveMember. +

    + +

    ubyte[] expand(ArchiveMember de) +
    Decompress the contents of archive member de + and return the expanded data. + Fills in properties + extractVersion, flags, + compressionMethod, time, + crc32, + compressedSize, + expandedSize, + expandedData[], + name[], extra[]. +

    + +

    ubyte[] data +
    Read Only: array representing the entire contents + of the archive. +

    + +

    uint diskNumber +
    Read Only: 0 since multi-disk zip archives are not supported. +

    + +

    uint diskStartDir +
    Read Only: 0 since multi-disk zip archives are not supported. +

    + +

    uint numEntries +
    Read Only: number of ArchiveMembers in the directory. +

    + +

    uint totalEntries +
    Read Only: same as totalEntries. +

    + +

    char[] comment +
    Read/Write: the archive comment. Must be less than + 65536 bytes in length. +

    + +

    ArchiveMember[char[]] directory +
    Read Only: array indexed by the name of each + member of the archive. + All the members of the archive can be accessed with a foreach + loop: +

    +
    +
    ZipArchive archive = new ZipArchive(data);
    +foreach (ArchiveMember am; archive)
    +{
    +    printf("member name is '%.*s'\n", am.name);
    +}

    +

    +

    + +

    class ArchiveMember +
    A member of the ZipArchive. +

    +

    +
    ushort madeVersion +
    Read Only +

    + +

    ushort extractVersion +
    Read Only +

    + +

    ushort flags +
    Read/Write: normally set to 0 +

    + +

    ushort compressionMethod +
    Read/Write: the only supported values are 0 (no compression) + and 8 (deflate). +

    + +

    date.DosFileTime time +
    Read/Write: Last modified time of the member. + It's in the DOS date/time format. +

    + +

    uint crc32 +
    Read Only: cyclic redundancy check (CRC) value +

    + +

    uint compressedSize +
    Read Only: size of data of member in compressed form. +

    + +

    uint expandedSize +
    Read Only: size of data of member in expanded form. +

    + +

    ushort diskNumber +
    Read Only: should be 0. +

    + +

    ushort internalAttributes +
    Read/Write +

    + +

    uint externalAttributes +
    Read/Write +

    + +

    char[] name +
    Read/Write: Usually the file name of the archive member; + it is used + to index the archive directory for the member. Each + member must have a unique name[]. + Do not change without removing member from the directory + first. +

    + +

    ubyte[] extra +
    Read/Write: extra data for this member. +

    + +

    char[] comment +
    Read/Write: comment associated with this member. +

    + +

    ubyte[] compressedData +
    Read Only: data of member in compressed form. +

    + +

    ubyte[] expandedData +
    Read/Write: data of member in uncompressed form. +
    + +
    + + Bugs: +
      +
    • Multi-disk zips not supported. +
    • Only Zip version 20 formats are supported. +
    • Only supports compression modes 0 (no compression) and 8 (deflate). +
    • Does not support encryption. +
    + + +
    +

    Feedback and Comments

    + + Add feedback and comments regarding this + page. + +
    +Copyright © 1999-2005 by Digital Mars, All Rights Reserved

    + + + + + + + + + + + diff -uNr dmd-0.129/dmd/html/d/phobos/std_zlib.html dmd-0.130/dmd/html/d/phobos/std_zlib.html --- dmd-0.129/dmd/html/d/phobos/std_zlib.html 1970-01-01 01:00:00.000000000 +0100 +++ dmd-0.130/dmd/html/d/phobos/std_zlib.html 2005-08-22 22:42:58.000000000 +0200 @@ -0,0 +1,253 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Digital Mars - The D Programming Language - std.zlib + + + + +www.digitalmars.com + +Home +| Search +| D +| Comments + +
    +Last update Mon Aug 22 2005 +


    + + + +
    +
    +
    + + + + + +
    +
    +
    D
    +
    Language
    +
    Phobos
    +
    Comparisons


    + +object
    +
    + +std
    std.base64
    std.boxer
    std.compiler
    std.conv
    std.ctype
    std.date
    std.file
    std.format
    std.gc
    std.intrinsic
    std.math
    std.md5
    std.mmfile
    std.openrj
    std.outbuffer
    std.path
    std.process
    std.random
    std.recls
    std.regexp
    std.socket
    std.socketstream
    std.stdint
    std.stdio
    std.cstream
    std.stream
    std.string
    std.system
    std.thread
    std.uri
    std.utf
    std.zip
    std.zlib
    +
    +std.windows
    +
    +std.linux
    +
    +std.c
    std.c.stdio
    +
    +std.c.windows
    +
    +std.c.linux
    +
    +
    +
    + + +

    std.zlib

    + + Compress / decompress data using the + zlib library. + +
    +
    uint adler32(uint adler, void[] buf) +
    Compute the Adler32 checksum of the data in buf[]. + adler is the starting value when computing a cumulative + checksum. +

    + +

    uint crc32(uint crc, void[] buf) +
    Compute the CRC32 checksum of the data in buf[]. + crc is the starting value when computing a cumulative + checksum. +

    + +

    class ZlibException +
    Thrown in the case of errors occurring in the following: +

    + +

    void[] compress(void[] buf) +
    void[] compress(void[] buf, int level) +
    Compresses the data in buf[] using compression + level level. The default value for level is 6, + legal values are 1..9, with 1 being the least compression and 9 + being the most. Returns the compressed data. +

    + +

    void[] uncompress(void[] buf) +
    void[] uncompress(void[] buf, uint destbufsize) +
    Decompresses the data in buf[]. + destbufsize is the size of the uncompressed data. It + need not be accurate, but the decompression will be faster if + the exact size is supplied. + Returns the decompressed data. +

    + +

    class Compress +
    Used when the data to be compressed is not all in one buffer. +

    + +

    + +
    this() +
    this(int level) +
    Construct. level is the same as for D.zlib.compress(). +

    + +

    void[] compress(void[] buf) +
    Compress the data in buf and return the compressed data. + The buffers returned from successive calls to this should be + concatenated together. +

    + +

    void[] flush() +
    void[] flush(int mode) +
    Compress and return any remaining data. + The returned data should be appended to that returned by compress(). + mode is one of the following: +
    +
    Z_SYNC_FLUSH +
    Syncs up flushing to the next byte boundary. + Used when more data is to be compressed later on. +
    Z_FULL_FLUSH +
    Syncs up flushing to the next byte boundary. + Used when more data is to be compressed later on, + and the decompressor needs to be restartable at this point. +
    Z_FINISH (default) +
    Used when finished compressing the data. +
    + +
    +

    + +

    class UnCompress +
    Used when the data to be decompressed is not all in one buffer. +

    + +

    + +
    this() +
    this(uint destbufsize) +
    Construct. destbufsize is the same as for D.zlib.uncompress(). +

    + +

    void[] uncompress(void[] buf) +
    Decompress the data in buf and return the decompressed data. + The buffers returned from successive calls to this should be + concatenated together. +

    + +

    void[] flush() +
    Decompress and return any remaining data. + The returned data should be appended to that returned by uncompress(). + The UnCompress object cannot be used further. + +
    +
    + + +
    +

    Feedback and Comments

    + + Add feedback and comments regarding this + page. + +
    +Copyright © 1999-2005 by Digital Mars, All Rights Reserved

    + + + + + + + + + + + diff -uNr dmd-0.129/dmd/html/d/phobos/style.css dmd-0.130/dmd/html/d/phobos/style.css --- dmd-0.129/dmd/html/d/phobos/style.css 1970-01-01 01:00:00.000000000 +0100 +++ dmd-0.130/dmd/html/d/phobos/style.css 2005-05-21 13:32:18.000000000 +0200 @@ -0,0 +1,86 @@ +body +{ + background: white; + color: black; + font-family: sans-serif; +} +h1 +{ + text-align: center; + text-decoration: underline; +} +blockquote +{ + font-size: smaller; + font-style: italic; + margin-left: 0; + margin-right: 0; +} +pre +{ + background: #e7e7e7; + color: #000066; + border: 2px solid #cccccc; + padding: 1ex; + width: 640px; +} + +body#toc +{ + background: #dddddd; + font-size: small; +} + +div#tocheading +{ + border-bottom: 2px solid gray; + font-size: larger; + font-weight: bold; + text-align: center; + margin-bottom: 1ex; + padding-bottom: 1ex; +} +div#tocheading b +{ + color: red; + font-size: 36pt; + font-family: serif; +} +body#toc ul +{ + border-bottom: 2px solid gray; + list-style-type: none; + margin-left: 0; + margin-top: 0; + padding-bottom: 1ex; + padding-left: 0; +} +div#toccopyright +{ + font-size: smaller; + margin-bottom: 1ex; + padding-top: 3px; +} + +div#heading +{ + border-bottom: 2px solid black; + padding-bottom: 1ex; +} +div#lastupdate +{ + font-size: smaller; + font-style: italic; +} +a#dlink +{ + color: red; + font-weight: bold; +} +div#copyright +{ + border-top: 2px solid black; + font-size: smaller; + margin-bottom: 2ex; + padding-top: 3px; +} \ Ingen nyrad vid filslut diff -uNr dmd-0.129/dmd/html/d/phobos.html dmd-0.130/dmd/html/d/phobos.html --- dmd-0.129/dmd/html/d/phobos.html 2005-08-06 21:59:06.000000000 +0200 +++ dmd-0.130/dmd/html/d/phobos.html 1970-01-01 01:00:00.000000000 +0100 @@ -1,2894 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - -D Programming Language - Phobos Runtime Library - - - - -www.digitalmars.com - -Home -| Search -| D - -
    -Last update Sat Aug 06 2005 -


    - - -

    Phobos

    D Runtime Library

    - -Phobos is the standard runtime library that comes with the -D language compiler. Also, check out the -wiki for Phobos. - - -

    Philosophy

    - - Each module in Phobos conforms as much as possible to the - following design goals. These are goals - rather than requirements because D is not a religion, - it's a programming language, and it recognizes that - sometimes the goals are contradictory and counterproductive - in certain situations, and programmers have - jobs that need to get done. - -
    - - -
    Machine and Operating System Independent Interfaces - -
    It's pretty well accepted that gratuitous non-portability - should be avoided. This should not be - construed, however, as meaning that access to unusual - features of an operating system should be prevented. - - -
    Simple Operations should be Simple - -
    A common and simple operation, like writing an array of - bytes to a file, should be simple to - code. I haven't seen a class library yet that simply and efficiently - implemented common, basic file I/O operations. - - -
    Classes should strive to be independent of one another - -
    It's discouraging to pull in a megabyte of code bloat - by just trying to read a file into an array of - bytes. Class independence also means that classes that turn - out to be mistakes can be deprecated and redesigned without - forcing a rewrite of the rest of the class library. - - -
    No pointless wrappers around C runtime library functions or OS API functions - -
    D provides direct access to C runtime library functions - and operating system API functions. - Pointless D wrappers around those functions just adds blather, - bloat, baggage and bugs. - - -
    Class implementations should use DBC - -
    This will prove that DBC (Contract Programming) is worthwhile. - Not only will it aid in debugging the class, but - it will help every class user use the class correctly. - DBC in the class library will have great leverage. - - -
    Use Exceptions for Error Handling - -
    See Error Handling in D. - -
    - -
    -

    Imports

    - - Runtime library modules can be imported with the - import statement. Each module falls into one of several - packages: - -
    -
    std -
    These are the core modules. -

    - -

    -
    std.windows -
    Modules specific to the Windows operating system. -

    - -

    std.linux -
    Modules specific to the Linux operating system. -

    - -

    std.c -
    Modules that are simply interfaces to C functions. - For example, interfaces to standard C library functions - will be in std.c, such as std.c.stdio would be the interface - to C's stdio.h. -

    - -

    -
    std.c.windows -
    Modules corresponding to the C Windows API functions. -

    - -

    std.c.linux -
    Modules corresponding to the C Linux API functions. -

    - -

    -
    - -
    - -
    -
    etc -
    This is the root of a hierarchy of modules mirroring the std - hierarchy. Modules in etc are not standard D modules. They are - here because they are experimental, or for some other reason are - not quite suitable for std, although they are still useful. -

    -

    - -
    -

    std: Core library modules

    - -
    - -
    std.base64 -
    Encode/decode base64 format. - -
    std.boxer -
    Box/unbox types. - -
    std.compiler -
    Information about the D compiler implementation. - -
    std.conv -
    Conversion of strings to integers. - -
    std.ctype -
    Simple character classification - -
    std.date -
    Date and time functions. Support locales. - -
    std.file -
    Basic file operations like read, write, append. - -
    std.format -
    Formatted conversions of values to strings. - -
    std.gc -
    Control the garbage collector. - -
    std.intrinsic -
    Compiler built in intrinsic functions - -
    std.math -
    Include all the usual math functions like sin, cos, atan, etc. - -
    std.md5 -
    Compute MD5 digests. - -
    std.mmfile -
    Memory mapped files. - -
    object -
    The root class of the inheritance hierarchy - -
    std.openrj -
    Basic database. - -
    std.outbuffer -
    Assemble data into an array of bytes - -
    std.path -
    Manipulate file names, path names, etc. - -
    std.process -
    Create/destroy threads. - -
    std.random -
    Random number generation. - -
    std.recls -
    Recursively search file system and (currently Windows - only) FTP sites. - -
    std.regexp -
    The usual regular expression functions. - -
    std.socket -
    Sockets. - -
    std.socketstream -
    Stream for a blocking, connected Socket. - -
    std.stdint -
    Integral types for various purposes. - -
    std.stdio -
    Standard I/O. - -
    std.cstream -
    Stream I/O. - -
    std.stream -
    Stream I/O. - -
    std.string -
    Basic string operations not covered by array ops. - -
    std.system -
    Inquire about the CPU, operating system. - -
    std.thread -
    One per thread. Operations to do on a thread. - -
    std.uri -
    Encode and decode Uniform Resource Identifiers (URIs). - -
    std.utf -
    Encode and decode utf character encodings. - -
    std.zip -
    Read/write zip archives. - -
    std.zlib -
    Compression / Decompression of data. - -
    - -
    -

    std.windows: Modules specific to the Windows operating system

    - -
    - -
    std.windows.syserror -
    Convert Windows error codes to strings. - -
    - -
    -

    std.linux: Modules specific to the Linux operating system

    - -
    -

    std.c: Interface to C functions

    - -
    - -
    std.c.stdio -
    Interface to C stdio functions like printf(). - -
    - -
    -

    std.c.windows: Interface to C Windows functions

    - -
    - -
    std.c.windows.windows -
    Interface to Windows APIs - -
    - -
    -

    std.c.linux: Interface to C Linux functions

    - -
    - -
    std.c.linux.linux -
    Interface to Linux APIs - -
    - - - -
    -

    std.base64

    - -Encodes/decodes base64 data. - -
    -

    std.compiler

    - -
    - -
    char[] name; -
    Vendor specific string naming the compiler, - for example: "Digital Mars D". -

    - -

    enum Vendor -
    Master list of D compiler vendors. -
    -
    DigitalMars -
    Digital Mars -
    -

    - -

    Vendor vendor; -
    Which vendor produced this compiler. -

    - -

    uint version_major; -
    uint version_minor; -
    The vendor specific version number, as in - version_major.version_minor. -

    - -

    uint D_major; -
    uint D_minor; -
    The version of the D Programming Language Specification - supported by the compiler. -

    - -

    - -
    -

    std.conv

    - - std.conv provides basic building blocks for conversions from - strings to integral types. They differ from the C functions atoi() - and atol() by not allowing whitespace or overflows. -

    - - For conversion to signed types, the grammar recognized is: - -

    -	Integer:
    -		Sign UnsignedInteger
    -		UnsignedInteger
    -
    -	Sign:
    -		+
    -		-
    -	
    - - For conversion to unsigned types, the grammar recognized is: - -
    -	UnsignedInteger:
    -		DecimalDigit
    -		DecimalDigit UnsignedInteger
    -	
    - - Any deviation from that grammar causes a ConvError exception - to be thrown. Any overflows cause a ConvOverflowError to - be thrown. -
    - -
    byte toByte(char[] s) -

    - -

    ubyte toUbyte(char[] s) -

    - -

    short toShort(char[] s) -

    - -

    ushort toUshort(char[] s) -

    - -

    int toInt(char[] s) -

    - -

    uint toUint(char[] s) -

    - -

    long toLong(char[] s) -

    - -

    ulong toUlong(char[] s) -

    - -

    - - -
    -

    std.ctype

    - -
    - -
    int isalnum(dchar c) -
    Returns !=0 if c is a letter or a digit. -

    - -

    int isalpha(dchar c) -
    Returns !=0 if c is an upper or lower case letter. -

    - -

    int iscntrl(dchar c) -
    Returns !=0 if c is a control character. -

    - -

    int isdigit(dchar c) -
    Returns !=0 if c is a digit. -

    - -

    int isgraph(dchar c) -
    Returns !=0 if c is a printing character except for the space character. -

    - -

    int islower(dchar c) -
    Returns !=0 if c is lower case. -

    - -

    int isprint(dchar c) -
    Returns !=0 if c is a printing character or a space. -

    - -

    int ispunct(dchar c) -
    Returns !=0 if c is a punctuation character. -

    - -

    int isspace(dchar c) -
    Returns !=0 if c is a space, tab, vertical tab, form feed, - carriage return, or linefeed. -

    - -

    int isupper(dchar c) -
    Returns !=0 if c is an upper case character. -

    - -

    int isxdigit(dchar c) -
    Returns !=0 if c is a hex digit (0..9, a..f, A..F). -

    - -

    int isascii(dchar c) -
    Returns !=0 if c is in the ascii character set. -

    - -

    dchar tolower(dchar c) -
    If c is upper case, return the lower case equivalent, - otherwise return c. -

    - -

    dchar toupper(dchar c) -
    If c is lower case, return the upper case equivalent, - otherwise return c. -

    - - -

    - -
    -

    std.date

    - - Dates are represented in several formats. The date implementation - revolves around a central type, d_time, from which other - formats are converted to and from. -

    - -

    -
    typedef d_time -
    Is a signed arithmetic type giving the time elapsed since - January 1, 1970. Negative values are for dates preceding 1970. - The time unit used is Ticks. Ticks are milliseconds - or smaller intervals. -

    - - The usual arithmetic operations can be performed on d_time, - such as adding, subtracting, etc. Elapsed time in Ticks can - be computed by subtracting a starting d_time from an ending - d_time. -

    - - An invalid value for d_time is represented by d_time.init. -

    - -

    int TicksPerSecond -
    A constant giving the number of Ticks per second for - this implementation. It will be at least 1000. -

    - -

    char[] toString(d_time t) -
    Converts t into a text string of the form: - "Www Mmm dd hh:mm:ss GMT+-TZ yyyy", - for example, "Tue Apr 02 02:04:57 GMT-0800 1996". - If t is invalid, "Invalid date" is returned. -

    - -

    char[] toUTCString(d_time t) -
    Converts t into a text string of the form: - "Www, dd Mmm yyyy hh:mm:ss UTC". - If t is invalid, "Invalid date" is returned. -

    - -

    char[] toDateString(d_time t) -
    Converts the date portion of t - into a text string of the form: - "Www Mmm dd yyyy", - for example, "Tue Apr 02 1996". - If t is invalid, "Invalid date" is returned. -

    - -

    char[] toTimeString(d_time t) -
    Converts the time portion of t - into a text string of the form: - "hh:mm:ss GMT+-TZ", - for example, "02:04:57 GMT-0800". - If t is invalid, "Invalid date" is returned. -

    - -

    d_time parse(char[] s) -
    Parses s as a textual date string, and - returns it as a d_time. If the string is not - a valid date, d_time.init is returned. -

    - -

    void toISO8601YearWeek(d_time t, out int year, out int week) -
    Compute year and week [1..53] from t. - The ISO 8601 week 1 is the first week of the year that includes - January 4. Monday is the first day of the week. -

    - -

    d_time getUTCtime() -
    Get current UTC time. -

    - -

    d_time UTCtoLocalTime(d_time t) -
    Convert from UTC time to local time. -

    - -

    d_time LocalTimetoUTC(d_time t) -
    Convert from local time to UTC time. -

    - -

    typedef DosFileTime -
    Type representing the DOS file date/time format. -

    - -

    d_time toDtime(DosFileTime time) -
    Convert from DOS file date/time to d_time. -

    - -

    DosFileTime toDosFileTime(d_time t) -
    Convert from d_time to DOS file date/time. - -
    - -
    -

    std.file

    - -
    - -
    class FileException -
    Exception thrown if file I/O errors. -

    - -

    void[] read(char[] name) -
    Read file name[], return array of bytes read. -

    - -

    void write(char[] name, void[] buffer) -
    Write buffer[] to file name[]. -

    - -

    void append(char[] name, void[] buffer) -
    Append buffer[] to file name[]. -

    - -

    void rename(char[] from, char[] to) -
    Rename file from[] to to[]. -

    - -

    void copy(char[] from, char[] to) -
    Copy file from[] to to[]. -

    - -

    void remove(char[] name) -
    Delete file name[]. -

    - -

    uint getSize(char[] name) -
    Get size of file name[]. -

    - -

    uint getAttributes(char[] name) -
    Get file name[] attributes. -

    - -

    int exists(char[] name) -
    Does name[] exist (file or directory)? -

    - -

    int isfile(char[] name) -
    Is name[] a file? Error if name[] doesn't exist. -

    - -

    int isdir(char[] name) -
    Is name[] a directory? Error if name[] doesn't exist. -

    - -

    void chdir(char[] name) -
    Change directory. -

    - -

    void mkdir(char[] name) -
    Make directory. -

    - -

    void rmdir(char[] name) -
    Remove directory. -

    - -

    char[] getcwd() -
    Get current directory. -

    - -

    char[][] listdir(char[] pathname) -
    Return contents of directory. -

    - - -

    - -
    -

    std.gc

    - - The garbage collector normally works behind the scenes without - needing any specific interaction. These functions are for - advanced applications that benefit from tuning the operation of the - collector. - -
    -
    class OutOfMemory -
    Thrown if garbage collector runs out of memory. -

    - -

    void addRoot(void* p) -
    Add p to list of roots. Roots are references to memory - allocated by the collector that are maintained in memory - outside the collector pool. The garbage collector will by - default look for roots in the stacks of each thread, the registers, - and the default static data segment. If roots are held elsewhere, - use addRoot() or addRange() to tell the collector - not to free the memory it points to. -

    - -

    void removeRoot(void* p) -
    Remove p from list of roots. -

    - -

    void addRange(void* pbot, void* ptop) -
    Add range to scan for roots. -

    - -

    void removeRange(void* pbot) -
    Remove range. -

    - -

    void fullCollect() -
    Run a full garbage collection cycle. - The collector normally runs synchronously with a storage - allocation request (i.e. it never happens when in code that - does not allocate memory). In some circumstances, for example - when a particular task is finished, it is convenient to explicitly - run the collector and free up all memory used by that task. - It can also be helpful to run a collection before starting a new - task that would be annoying if it ran a collection in - the middle of that task. - Explicitly running a collection can also be done in a separate very low priority - thread, so that if the program is idly waiting for input, memory - can be cleaned up. -

    - - -

    void genCollect() -
    Run a generational garbage collection cycle. - Takes less time than a fullCollect(), but isn't - as effective. -

    - -

    void minimize() -
    Minimize physical memory usage. -

    - - -

    void disable() -
    Temporarilly disable garbage collection cycle. - This is used for brief time critical sections of code, - so the amount of time it will take is predictable. - If the collector runs out of memory while it is disabled, - it will throw an OutOfMemory exception. - The disable() function calls can be nested, but must be - matched with corresponding enable() calls. -

    - - -

    void enable() -
    Reenable garbage collection cycle after being disabled - with disable(). - It is an error to call more enable()s than - disable()s. - -
    - -
    -

    std.intrinsic

    - - Intrinsic functions are functions built in to the compiler, - usually to take advantage of specific CPU features that - are inefficient to handle via external functions. - The compiler's optimizer and code generator are fully - integrated in with intrinsic functions, bringing to bear - their full power on them. - This can result in some surprising speedups. - -
    - -
    int bsf(uint v) -
    Scans the bits in v starting with bit 0, looking - for the first set bit. - -
    int bsr(uint v) -
    Scans the bits in v from the most significant bit - to the least significant bit, looking - for the first set bit. -

    - - Both return the bit number of the first set bit. - The return value is undefined if v is zero. -

    - - Example
    - -

    -
    -
    
    -	import std.intrinsic;
    -
    -	int main()
    -	{   
    -	    uint v;
    -	    int x;
    -
    -	    v = 0x21;
    -	    x = bsf(v);
    -	    printf("bsf(x%x) = %d\n", v, x);
    -	    x = bsr(v);
    -	    printf("bsr(x%x) = %d\n", v, x);
    -	    return 0;
    -	} 
    -	

    - - Output
    -

    -	bsf(x21) = 0
    -	bsr(x21) = 5
    -	
    - -
    int bt(uint* p, uint index) -
    Tests the bit. - -
    int btc(uint* p, uint index) -
    Tests and complements the bit. - -
    int btr(uint* p, uint index) -
    Tests and resets (sets to 0) the bit. - -
    int bts(uint* p, uint index) -
    Tests and sets the bit. -

    - - p is a non-NULL pointer to an array of uints. - index is a bit number, starting with bit 0 of p[0], - and progressing. It addresses bits like the expression: -

    -	p[index / (uint.size*8)] & (1 << (index & ((uint.size*8) - 1)))
    -	
    -

    - - All return a non-zero value if the bit was set, and a zero - if it was clear. -

    - - Example - -

    -
    -
    
    -	import std.intrinsic;
    -
    -	int main()
    -	{   
    -	    uint array[2];
    -
    -	    array[0] = 2;
    -	    array[1] = 0x100;
    -
    -	    printf("btc(array, 35) = %d\n", btc(array, 35));
    -	    printf("array = [0]:x%x, [1]:x%x\n", array[0], array[1]);
    -
    -	    printf("btc(array, 35) = %d\n", btc(array, 35));
    -	    printf("array = [0]:x%x, [1]:x%x\n", array[0], array[1]);
    -
    -	    printf("bts(array, 35) = %d\n", bts(array, 35));
    -	    printf("array = [0]:x%x, [1]:x%x\n", array[0], array[1]);
    -
    -	    printf("btr(array, 35) = %d\n", btr(array, 35));
    -	    printf("array = [0]:x%x, [1]:x%x\n", array[0], array[1]);
    -
    -	    printf("bt(array, 1) = %d\n", bt(array, 1));
    -	    printf("array = [0]:x%x, [1]:x%x\n", array[0], array[1]);
    -
    -	    return 0;
    -	} 
    -

    - - Output -

    -	btc(array, 35) = 0
    -	array = [0]:x2, [1]:x108
    -	btc(array, 35) = -1
    -	array = [0]:x2, [1]:x100
    -	bts(array, 35) = 0
    -	array = [0]:x2, [1]:x108
    -	btr(array, 35) = -1
    -	array = [0]:x2, [1]:x100
    -	bt(array, 1) = -1
    -	array = [0]:x2, [1]:x100
    -
    -
    uint bswap(uint x) -
    Swaps bytes in a 4 byte uint end-to-end, i.e. byte 0 becomes - byte 3, byte 1 becomes byte 2, byte 2 becomes byte 1, byte 3 - becomes byte 0. -

    - -

    ubyte inp(uint port_address) -
    ushort inpw(uint port_address) -
    uint inpl(uint port_address) -
    Reads I/O port at port_address. -

    - -

    ubyte outp(uint port_address, ubyte value) -
    ushort outpw(uint port_address, ushort value) -
    uint outpl(uint port_address, uint value) -
    Writes and returns value to I/O port at port_address. -

    - -

    real cos(real) -
    real fabs(real) -
    real rint(real) -
    long rndtol(real) -
    real sin(real) -
    real sqrt(real) -
    Intrinsic verions of the math functions of the same name. - -
    - -
    -

    std.math

    - -
    - -
    const real PI -
    const real LOG2 -
    const real LN2 -
    const real LOG2T -
    const real LOG2E -
    const real E -
    const real LOG10E -
    const real LN10 -
    const real PI_2 -
    const real PI_4 -
    const real M_1_PI -
    const real M_2_PI -
    const real M_2_SQRTPI -
    const real SQRT2 -
    const real SQRT1_2 -
    Math constants. -

    - -

    real acos(real) -
    real asin(real) -
    real atan(real) -
    real atan2(real, real) -

    - -

    real cos(real x) -
    Compute cosine of x. x is in radians.
    - Special values: - - - -
    x - return value - invalid? -
    ±INFINITY - NAN - yes -
    -

    - -

    real sin(real x) -
    Compute sine of x. x is in radians.
    - Special values: - - - - -
    x - return value - invalid? -
    ±0.0 - ±0.0 - no -
    ±INFINITY - NAN - yes -
    -

    - -

    real tan(real x) -
    Compute tangent of x. x is in radians.
    - Special values: - - - - -
    x - return value - invalid? -
    ±0.0 - ±0.0 - no -
    ±INFINITY - NAN - yes -
    -

    - -

    real cosh(real) -
    real sinh(real) -
    real tanh(real) -
    real exp(real) -

    - -

    real frexp(real value, out int exp) -
    Calculate and return x and exp such that:
    - value=x*2exp
    - .5 <= |x| < 1.0
    - x has same sign as value. -
    - Special values: - - - - - - -
    value x exp -
    +-0.0 +-0.0 0 -
    +INFINITY +INFINITY int.max -
    -INFINITY -INFINITY int.min -
    +-NAN +-NAN int.min -
    -

    - -

    real ldexp(real n, int exp) -
    Compute n * 2exp -

    - -

    real log(real x) -
    Calculate the natural logarithm of x. -
    - Special values: - - - - - -
    x return value divide by 0? invalid? -
    ±0.0 -INFINITY yes no -
    < 0.0 NAN no yes -
    +INFINITY +INFINITY no no -
    -

    - -

    real log10(real x) -
    Calculate the base-10 logarithm of x. -
    - Special values: - - - - - -
    x return value divide by 0? invalid? -
    ±0.0 -INFINITY yes no -
    < 0.0 NAN no yes -
    +INFINITY +INFINITY no no -
    -

    - -

    real modf(real, real*) -

    - -

    real pow(real, real) -

    - -

    real sqrt(real x) -
    creal sqrt(creal x) -
    Compute square root of x.
    - Special values: - - - - - -
    x - return value - invalid? -
    -0.0 - -0.0 - no -
    <0.0 - NAN - yes -
    +INFINITY - +INFINITY - no -
    -

    - -

    real ceil(real) -
    real floor(real) -

    - -

    real log1p(real x) -
    Calculates the natural logarithm of - 1 + x. - For very small x, log1p(x) will be more accurate than - log(1 + x). -
    - Special values: - - - - - - -
    x - log1p(x) - divide by 0? - invalid? -
    ±0.0 - ±0.0 - no - no -
    -1.0 - -INFINITY - yes - no -
    <-1.0 - NAN - no - yes -
    +INFINITY - -INFINITY - no - no -
    -

    - -

    real expm1(real x) -
    Calculates the value of the natural logarithm base (e) - raised to the power of x, minus 1. - For very small x, expm1(x) is more accurate - than exp(x)-1. -
    - Special values: - - - - - -
    x - ex-1 -
    ±0.0 - ±0.0 -
    +INFINITY - +INFINITY -
    -INFINITY - -1.0 -
    -

    - -

    real atof(char*) -
    Math functions. -

    - -

    real hypot(real x, real y) -
    - Calculates the length of the - hypotenuse of a right-angled triangle with sides of length x and y. - The hypotenuse is the value of the square root of - the sums of the squares of x and y: -
    -	sqrt(x2 + y2)
    - Note that hypot(x,y), hypot(y,x) and - hypot(x,-y) are equivalent.
    - Special values: - - - - - -
    x - y - return value - invalid? -
    x - +-0.0 - fabs(x) - no -
    +-INFINITY - y - +INFINITY - no -
    +-INFINITY - NAN - +INFINITY - no -
    -

    - -

    int isnan(real e) -
    Is number a nan? -

    - -

    int isfinite(real e) -
    Is number finite? -

    - -

    int isnormal(float f) -
    int isnormal(double d) -
    int isnormal(real e) -
    Is number normalized? -

    - -

    int issubnormal(float f) -
    int issubnormal(double d) -
    int issubnormal(real e) -
    Is number subnormal? (Also called "denormal".) - Subnormals have a 0 exponent and a 0 most significant mantissa bit. -

    - -

    int isinf(real e) -
    Is number infinity? -

    - -

    int signbit(real e) -
    Get sign bit. -

    - -

    real copysign(real to, real from) -
    Copy sign. -

    - -

    - -
    -

    std.md5

    - -Computes MD5 digests of arbitrary data. MD5 digests are 16 byte quantities -that are like a checksum or crc, but are more robust. -

    -There are two ways to do this. The first does it all in one function call -to sum(). The second is for when the data is buffered. -

    -The routines and algorithms are derived from the -RSA Data Security, Inc. MD5 Message-Digest Algorithm. -

    - -

    -
    void sum(ubyte[16] digest, void[] data) -
    Compute MD5 digest from data. -

    - -

    void printDigest(ubyte[16] digest) -
    Print MD5 digest to standard output. -

    - -

    struct MD5_CTX -
    Use when data to be digested is buffered. -

    - -

    - -
    void start() -
    Begins an MD5 message-digest operation. -

    - -

    void update(void[] input) -
    Continues an MD5 message-digest - operation, processing another message block input, - and updating the context. -

    - -

    void finish(ubyte[16] digest) -
    Ends an MD5 message-digest operation and writes the result - to digest. - -
    - -
    - - -

    Example

    - -

    -
    -
    
    -// This code is derived from the
    -// RSA Data Security, Inc. MD5 Message-Digest Algorithm.
    -
    -import std.md5;
    -import std.string;
    -import std.c.stdio;
    -
    -int main(char[][] args)
    -{
    -    for (int i = 1; i < args.length; i++)
    -	 MDFile(args[i]);
    -    return 0;
    -}
    -
    -/* Digests a file and prints the result. */
    -void MDFile(char[] filename)
    -{
    -    FILE* file;
    -    MD5_CTX context;
    -    int len;
    -    ubyte [4 * 1024] buffer;
    -    ubyte digest[16];
    -
    -    if ((file = fopen(std.string.toStringz(filename), "rb")) == null)
    -	printf("%.*s can't be opened\n", filename);
    -    else
    -    {
    -	context.start();
    -	while ((len = fread(buffer, 1, buffer.size, file)) != 0)
    -	    context.update(buffer[0 .. len]);
    -	context.finish(digest);
    -	fclose(file);
    -
    -	printf("MD5 (%.*s) = ", filename);
    -	printDigest(digest);
    -	printf("\n");
    -    }
    -}
    -

    - - -


    -

    object

    - -This module is implicitly imported. - -
    - -
    class Object -
    All class objects in D inherit from Object. -

    -

    -
    static int printf(char* format, ...); -
    C printf function. -

    - -

    char[] toString() -
    Convert Object to a human readable string. -

    - -

    uint toHash() -
    Compute hash function for Object. -

    - -

    int opCmp(Object obj) -
    Compare with another Object obj. Returns: -
    -
    <0 for (this < obj) -
    =0 for (this == obj) -
    >0 for (this > obj) -
    -

    -

    - -
    class ClassInfo -
    Runtime type information about a class. -

    - -

    class Exception -
    All exceptions should be derived from class Exception. -

    - -

    - -
    -

    std.outbuffer

    - -
    - -
    class OutBuffer -
    OutBuffer provides a way to build up an array of bytes out - of raw data. It is useful for things like preparing an - array of bytes to write out to a file. - OutBuffer's byte order is the format native to the computer. - To control the byte order (endianness), use a class derived - from OutBuffer. - To convert an array of bytes back into raw data, use InBuffer. -

    - -

    - -
    void reserve(uint nbytes) -
    Preallocate nbytes more to the size of the internal - buffer. This is a speed optimization, a good guess at the maximum - size of the resulting buffer will improve performance by eliminating - reallocations and copying. -

    - -

    void write(ubyte[] bytes) -
    void write(ubyte b) -
    void write(byte b) -
    void write(char c) -
    void write(ushort w) -
    void write(short s) -
    void write(wchar c) -
    void write(uint w) -
    void write(int i) -
    void write(ulong l) -
    void write(long l) -
    void write(float f) -
    void write(double f) -
    void write(real f) -
    void write(char[] s) -
    void write(OutBuffer buf) -
    Append data to the internal buffer. -

    - -

    void fill0(uint nbytes) -
    Append nbytes of 0 to the internal buffer. -

    - -

    void alignSize(uint alignsize) -
    0-fill to align on an alignsize boundary. - alignsize must be a power of 2. -

    - -

    void align2() -
    Optimize common special case alignSize(2) -

    - -

    void align4() -
    Optimize common special case alignSize(4) -

    - -

    ubyte[] toBytes() -
    Convert internal buffer to array of bytes. -

    - -

    char[] toString() -
    Convert internal buffer to array of chars. -

    - -

    void vprintf(char[] format, va_list args) -
    Append output of vprintf() to internal buffer. -

    - -

    void printf(char[] format, ...) -
    Append output of printf() to internal buffer. -

    - -

    void spread(uint index, uint nbytes) -
    At offset index into buffer, create nbytes - of space by shifting upwards all data past index. -

    - -

    -
    - -
    -

    std.path

    - -
    - -
    const char[] sep; -
    Character used to separate directory names in a path. -

    - -

    const char[] altsep; -
    Alternate version of sep[], used in Windows. -

    - -

    const char[] pathsep; -
    Path separator string. -

    - -

    const char[] linesep; -
    String used to separate lines. -

    - -

    const char[] curdir; -
    String representing the current directory. -

    - -

    const char[] pardir; -
    String representing the parent directory. -

    - - -

    char[] getExt(char[] fullname) -
    Get extension. - For example, "d:\path\foo.bat" returns "bat". -

    - - -

    char[] getBaseName(char[] fullname) -
    Get base name. - For example, "d:\path\foo.bat" returns "foo.bat". -

    - - -

    char[] getDirName(char[] fullname) -
    Get directory name. - For example, "d:\path\foo.bat" returns "d:\path". -

    - - -

    char[] getDrive(char[] fullname) -
    Get drive. - For example, "d:\path\foo.bat" returns "d:". - Returns null string on systems without the concept of a drive. -

    - - -

    char[] defaultExt(char[] fullname, char[] ext) -
    Put a default extension on fullname if it doesn't already - have an extension. -

    - - -

    char[] addExt(char[] fullname, char[] ext) -
    Add file extension or replace existing extension. -

    - - -

    int isabs(char[] path) -
    Determine if absolute path name. -

    - - -

    char[] join(char[] p1, char[] p2) -
    Join two path components. -

    - - -

    int fncharmatch(dchar c1, dchar c2) -
    Match file name characters. - Case sensitivity depends on the operating system. -

    - - -

    int fnmatch(char[] name, char[] pattern) -
    Match filename strings with pattern[], using the following wildcards: -
    -
    * match 0 or more characters -
    ? match any character -
    [chars] match any character that appears between the [] -
    [!chars] match any character that does not appear between the [! ] -
    - Matching is case sensitive on a file system that is case sensitive.
    - Returns: -
    -
    !=0 match -
    0 no match -
    -

    - - -

    - -
    -

    std.process

    - -
    - -
    int system(char[] command) -
    Execute command in a command shell. - Returns exit status of command. -

    - -

    int execv(char[] program, char[][] arguments) -
    int execve(char[] program, char[][] arguments, char[][] environment) -
    int execvp(char[] program, char[][] arguments) -
    int execvpe(char[] program, char[][] arguments, char[][] environment) -
    Execute program, passing it the arguments - and the environment, returning the exit status. - The 'p' versions of exec search the PATH environment variable - setting for program. -

    - - -

    - -
    -

    std.random

    - -
    - -
    void rand_seed(uint seed, uint index) -
    The random number generator is seeded at program - startup with a random value. This ensures that each program - generates a different sequence of random numbers. - To generate a repeatable sequence, use rand_seed() to - start the sequence. seed and index start it, and each - successive value increments index. This means that the - nth random number of the sequence can be directly generated - by passing index + n to rand_seed(). -

    - -

    uint rand() -
    Get next random number in sequence. -

    - -

    - -
    -

    std.socketstream

    - -
    - -
    class SocketStream : std.stream.Stream -
    SocketStream is a stream for a blocking, - connected Socket. -

    -

    -
    this(Socket sock, std.stream.FileMode mode) -
    Constructs a SocketStream with the specified - Socket and FileMode flags. -
    this(Socket sock) -
    Uses mode FileMode.In | FileMode.Out. -

    - -

    Socket socket -
    Property to get the Socket that is being - streamed. -

    - -

    uint readBlock(void* buffer, uint size) -
    Attempts to read the entire block, waiting if necessary. -

    - -

    char[] readLine() -
    wchar[] readLineW() -
    Read a line. Safely does not use ungetc/ungetcw. -

    - -

    uint writeBlock(void* buffer, uint size) -
    Attempts to write the entire block, waiting if necessary. -

    - -

    bit eof() -
    Returns true if a remote disconnection has been detected. -

    - -

    char[] toString() -
    Does not return the entire stream because that would - require the remote connection to be closed. -

    - -

    void close() -
    Close the Socket. -

    -

    - -
    - - -

    Notes

    - - For Win32 systems, link with ws2_32.lib. - -

    Example

    - - See /dmd/samples/d/htmlget.d. - -
    -

    std.stdint

    - - D constrains integral types to specific sizes. But efficiency - of different sizes varies from machine to machine, - pointer sizes vary, and the maximum integer size varies. - stdint offers a portable way of trading off size - vs efficiency, in a manner compatible with the stdint.h - definitions in C. -

    - - The exact aliases are types of exactly the specified number of bits. - The at least aliases are at least the specified number of bits - large, and can be larger. - The fast aliases are the fastest integral type supported by the - processor that is at least as wide as the specified number of bits. -

    - - The aliases are: -

    - - - - - - - - - - -
    Exact Alias - Description - At Least Alias - Description - Fast Alias - Description -
    int8_t - exactly 8 bits signed - int_least8_t - at least 8 bits signed - int_fast8_t - fast 8 bits signed -
    uint8_t - exactly 8 bits unsigned - uint_least8_t - at least 8 bits unsigned - uint_fast8_t - fast 8 bits unsigned - -
    int16_t - exactly 16 bits signed - int_least16_t - at least 16 bits signed - int_fast16_t - fast 16 bits signed -
    uint16_t - exactly 16 bits unsigned - uint_least16_t - at least 16 bits unsigned - uint_fast16_t - fast 16 bits unsigned - -
    int32_t - exactly 32 bits signed - int_least32_t - at least 32 bits signed - int_fast32_t - fast 32 bits signed -
    uint32_t - exactly 32 bits unsigned - uint_least32_t - at least 32 bits unsigned - uint_fast32_t - fast 32 bits unsigned - -
    int64_t - exactly 64 bits signed - int_least64_t - at least 64 bits signed - int_fast64_t - fast 64 bits signed -
    uint64_t - exactly 64 bits unsigned - uint_least64_t - at least 64 bits unsigned - uint_fast64_t - fast 64 bits unsigned -
    -

    - - The ptr aliases are integral types guaranteed to be large enough - to hold a pointer without losing bits: -

    - - - - -
    Alias - Description -
    intptr_t - signed integral type large enough to hold a pointer -
    uintptr_t - unsigned integral type large enough to hold a pointer -
    -

    - - The max aliases are the largest integral types: -

    - - - - -
    Alias - Description -
    intmax_t - the largest signed integral type -
    uintmax_t - the largest unsigned integral type -
    - -


    -

    std.stdio

    - - Standard I/O functions that extend std.c.stdio. - std.c.stdio is automatically imported when importing - std.stdio. - -
    -
    void writef(...); -
    Arguments are formatted per the - - format strings and written to stdout. -

    - -

    void writefln(...); -
    Same as writef, but a newline is appended - to the output. -

    - -

    void fwritef(FILE* fp, ...); -
    Same as writef, but output is sent to the - stream fp instead of stdout. -

    - -

    void fwritefln(FILE* fp, ...); -
    Same as writefln, but output is sent to the - stream fp instead of stdout. -

    - -

    void writefx(FILE* fp, TypeInfo[] arguments, void* argptr, int newline = false); -
    Same as writef, but output is sent to the - stream fp instead of stdout, the variadic inputs - are expanded to the arguments and argptr pair and - the newline is an optional parameter with no newline by default. -

    -

    - -
    -

    std.stream

    - - - -
    -
    interface InputStream -
    InputStream is the interface for readable streams. -

    -

    - -
    void readExact(void* buffer, uint size) -
    Read exactly size bytes into the buffer, throwing a - ReadException if it is not correct. -

    - -

    uint read(ubyte[] buffer) -
    Read a block of data big enough to fill the given array and - return the actual number of bytes read. Unfilled bytes are not - modified. -

    - -

    void read(out byte x) -
    void read(out ubyte x) -
    void read(out short x) -
    void read(out ushort x) -
    void read(out int x) -
    void read(out uint x) -
    void read(out long x) -
    void read(out ulong x) -
    void read(out float x) -
    void read(out double x) -
    void read(out real x) -
    void read(out ifloat x) -
    void read(out idouble x) -
    void read(out ireal x) -
    void read(out cfloat x) -
    void read(out cdouble x) -
    void read(out creal x) -
    void read(out char x) -
    void read(out wchar x) -
    void read(out dchar x) -
    void read(out char[] s) -
    void read(out wchar[] s) -
    Read a basic type or counted string, throwing a - ReadException if it could not be read. Outside of - byte, ubyte, and char, the format is implementation-specific - and should not be used except as opposite actions to - write. -

    - -

    char[] readLine() -
    char[] readLine(char[] buffer) -
    wchar[] readLineW() -
    wchar[] readLineW(wchar[] buffer) -
    Read a line that is terminated with some combination - of carriage return and line feed or end-of-file. The - terminators are not included. The wchar version is - identical. When a buffer is supplied as a parameter it is - filled unless the content does not fit in the buffer, in - which case a new buffer is allocated, filled and returned. -

    - -

    char[] readString(uint length) -
    Read a string of the given length, throwing - ReadException if there was a problem. -

    - -

    wchar[] readStringW(uint length) -
    Read a string of the given length, throwing - ReadException if there was a problem. The file - format is implementation-specific and should not be - used except as opposite actions to write. -

    - -

    char getc() -
    wchar getcw() -
    Read and return the next character in the stream. - This is the only method that will handle ungetc - properly. getcw's format is implementation-specific. -

    - -

    char ungetc(char c) -
    wchar ungetcw(wchar c) -
    Push a character back onto the stream. They will - be returned in first-in last-out order from getc/getcw. -

    - -

    int scanf(char[] fmt, ...) -
    int vscanf(char[] fmt, va_list args) -
    Scan a string from the input using a similar form - to C's scanf. -

    - -

    uint available() -
    Retrieve the nubmer of bytes available for immediate reading. -

    -

    - -

    -
    interface OutputStream -
    OutputStream is the interface for writable streams. -

    -

    - -
    void writeExact(void* buffer, uint size) -
    Write exactly size bytes from buffer, or throw - a WriteException if that could not be done. -

    - -

    uint write(ubyte[] buffer) -
    Write as much of the buffer as possible, returning the - number of bytes written. -

    - -

    void write(byte x) -
    void write(ubyte x) -
    void write(short x) -
    void write(ushort x) -
    void write(int x) -
    void write(uint x) -
    void write(long x) -
    void write(ulong x) -
    void write(float x) -
    void write(double x) -
    void write(real x) -
    void write(ifloat x) -
    void write(idouble x) -
    void write(ireal x) -
    void write(cfloat x) -
    void write(cdouble x) -
    void write(creal x) -
    void write(char x) -
    void write(wchar x) -
    void write(dchar x) -
    void write(char[] s) -
    void write(wchar[] s) -
    Write a basic type or counted string. Outside of byte, ubyte, - and char, the format is implementation-specific and should only be - used in conjunction with read. -

    - -

    void writeLine(char[] s) -
    Write a line of text, appending the line with an - operating-system-specific line ending. -

    - -

    void writeLineW(wchar[] s) -
    Write a line of text, appending the line with an - operating-system-specific line ending. The format is - implementation-specific. -

    - -

    void writeString(char[] s) -
    Write a string of text, throwing WriteException if - it could not be fully written. -

    - -

    void writeStringW(wchar[] s) -
    Write a string of text, throwing WriteException if - it could not be fully written. The format is - implementation-dependent. -

    - -

    uint printf(char[] format, ...) -
    uint vprintf(char[] format, va_list args) -
    Print a formatted string into the stream using printf-style - syntax, returning the number of bytes written. -

    - -

    void writef(...) -
    void writefln(...) -
    Print a formatted string into the stream using writef-style - syntax. See std.format -

    -

    - -

    -
    class Stream : InputStream,OutputStream -
    Stream is the base abstract class from which the other - stream classes derive. Stream's byte order is the format - native to the computer. -

    -

    -
    bit readable -
    Indicates whether this stream can be read from. -

    - -

    bit writeable -
    Indicates whether this stream can be written to. -

    - -

    bit seekable -
    Indicates whether this stream can be seeked within. -

    - -

    Reading

    -
    These methods require that the readable flag be set. - Problems with reading result in a ReadException being thrown. - Stream implements the InputStream interface in addition to the - following methods. -

    - -

    uint readBlock(void* buffer, uint size) -
    Read up to size bytes into the buffer and return the number - of bytes actually read. -

    - -

    Writing

    -
    These methods require that the writeable flag be set. - Problems with writing result in a WriteException being thrown. - Stream implements the OutputStream interface in addition to the - following methods. -

    - -

    uint writeBlock(void* buffer, uint size) -
    Write up to size bytes from buffer in the - stream, returning the actual number of bytes that were written. -

    - -

    void copyFrom(Stream s) -
    Copies all data from s into this stream. - This may throw ReadException or WriteException - on failure. This restores the file position - of s so that it is unchanged. - -
    void copyFrom(Stream s, uint count) -
    Copy a specified number of bytes from the given stream - into this one. This may throw ReadException or - WriteException on failure. Unlike the previous form, - this doesn't restore the file position of s. - -

    Seeking

    -
    These methods require that the seekable flag be set. - Problems with seeking result in a SeekException being thrown. -

    - -

    ulong seek(long offset, SeekPos whence) -
    Change the current position of the stream. whence is - either SeekPos.Set, in which case the offset is an absolute - index from the beginning of the stream, SeekPos.Current, in - which case the offset is a delta from the current position, or - SeekPos.End, in which case the offset is a delta from the - end of the stream (negative or zero offsets only make sense in - that case). This returns the new file position. -

    - -

    ulong seekSet(long offset) -
    ulong seekCur(long offset) -
    ulong seekEnd(long offset) -
    Aliases for their normal seek counterparts. -

    - -

    ulong position() -
    void position(ulong pos) -
    Retrieve or set the file position, identical to calling - seek(0, SeekPos.Current) or - seek(pos, SeekPos.Set) respectively. -

    - -

    ulong size() -
    Retrieve the size of the stream in bytes. -

    - -

    bit eof() -
    Return whether the current file position is the same as the - end of the file. This does not require actually reading past the - end of the file, as with stdio. -

    - -

    bit isOpen() -
    Return true if the stream is currently open. -

    - -

    void flush() -
    Flush pending output if appropriate. -

    - -

    void close() -
    Close the stream, flushing output if appropriate. -

    - -

    char[] toString() -
    Read the entire stream and return it as a string. -

    - -

    uint toHash() -
    Get a hash of the stream by reading each byte and using it in - a CRC-32 checksum. -

    -

    - -

    -
    class BufferedStream : Stream -
    This subclass is for buffering a source stream. A buffered - stream must be closed explicitly to ensure the final buffer - content is written to the source stream. -

    - -

    -
    this(Stream source, uint bufferSize = 8192) -
    Create a buffered stream for the stream source with - the buffer size bufferSize. -
    - -

    -
    class File : Stream -
    This subclass is for file system streams. -

    - -

    -
    this() -
    this(char[] filename, FileMode mode = FileMode.In) -
    Create the stream with no open file, an open file in read - mode, or an open file with explicit file mode. mode, - if given, is a combination of FileMode.In (indicating a file - that can be read) and FileMode.Out (indicating a file that can - be written). Opening a file for reading that doesn't exist - will error. Opening a file for writing that doesn't exist - will create the file. The FileMode.OutNew mode will - open the file for writing and reset the legnth to zero. The - FileMode.Append mode will open the file for writing and - move the file position to the end of the file. -

    - -

    void open(char[] filename, FileMode mode = FileMode.In) -
    Open a file for the stream, in an identical manner to the - constructors. -

    - -

    void create(char[] filename, FileMode mode = FileMode.OutNew) -
    Create a file for the stream. -

    - -

    void close() -
    Close the current file if it is open; otherwise it does - nothing. -

    - -

    uint readBlock(void* buffer, uint size) -
    uint writeBlock(void* buffer, uint size) -
    ulong seek(long offset, SeekPos rel) -
    Overrides of the Stream methods. -

    -

    - -

    -
    class BufferedFile : BufferedStream -
    This subclass is for buffered file system streams. It is - a convenience class for wrapping a File in a BufferedStream. - A buffered stream must be closed explicitly to ensure the final - buffer content is written to the file. -

    - -

    -
    this() -
    this(char[] filename, FileMode mode = FileMode.In, uint buffersize = 8192) -
    this(File file, uint buffersize = 8192) -
    void open(char[] filename, FileMode mode = FileMode.In) -
    void create(char[] filename, FileMode mode = FileMode.OutNew) -
    void close() -
    uint readBlock(void* buffer, uint size) -
    uint writeBlock(void* buffer, uint size) -
    ulong seek(long offset, SeekPos rel) -
    Overrides of the Stream methods. -

    -

    - -

    -
    enum BOM -
    UTF byte-order-mark signatures -
    -
    UTF8 -
    UTF-8 -
    UTF16LE -
    UTF-16 Little Endian -
    UTF16BE -
    UTF-16 Big Endian -
    UTF32LE -
    UTF-32 Little Endian -
    UTF32BE -
    UTF-32 Big Endian -
    -

    - -

    class EndianStream : Stream -
    This subclass wraps a stream with big-endian or - little-endian byte order swapping. UTF Byte-Order-Mark (BOM) - signatures can be read and deduced or written. -

    -

    -
    this(Stream source, Endian end = std.system.endian) -
    Create the endian stream for the source stream - source with endianness end. The default - endianness is the native byte order. The Endian type is - defined in the std.system module. -
    Endian endian -
    property for endianness of the source stream -
    int readBOM(int ungetCharSize = 1) -
    Return -1 if no BOM and otherwise read the BOM and return it. - If there is no BOM or if bytes beyond the BOM are read - then the bytes read are pushed back onto the ungetc buffer or - ungetcw buffer. Pass ungetCharSize == 2 to use ungetcw instead - of ungetc when no BOM is present. -
    void writeBOM(BOM b) -
    Write the BOM b to the source stream -
    final void fixBO(void* buffer, uint size) -
    fix the byte order of the given buffer to match the native order -

    - -

    -

    -
    class TArrayStream(Buffer) : Stream -
    This subclass wraps an array-like buffer with a stream - interface. The type Buffer must support the length - property and reading ubyte slices. -

    -

    -
    this(Buffer buf) -
    Create the stream for the the buffer buf. -
    uint readBlock(void* buffer, uint size) -
    uint writeBlock(void* buffer, uint size) -
    ulong seek(long offset, SeekPos rel) -
    char[] toString() -
    Overrides of Stream methods. -

    - -

    - -

    -
    class MemoryStream : TArrayStream!(ubyte[]) -
    This subclass reads and constructs an array of bytes in - memory. -

    - -

    -
    this() -
    this(ubyte[] data) -
    Create the output buffer and setup for reading, writing, - and seeking. The second constructor loads it with specific - input data. -

    - -

    ubyte[] data() -
    Get the current memory data in total. -

    - -

    uint readBlock(void* buffer, uint size) -
    uint writeBlock(void* buffer, uint size) -
    ulong seek(long offset, SeekPos rel) -
    char[] toString() -
    Overrides of Stream methods. -

    -

    - -

    -
    class SliceStream : Stream -
    This subclass slices off a portion of another stream, making - seeking relative to the boundaries of the slice. It could be - used to section a large file into a set of smaller files, such as - with tar archives. -

    - -

    -
    this(Stream base, int low) -
    Indicate both the base stream to use for reading from and the - low part of the slice. The high part of the slice is dependent - upon the end of the base stream, so that if you write beyond the - end it resizes the stream normally. -

    - -

    this(Stream base, int low, int high) -
    Indicate the high index as well. Attempting to read or write - past the high index results in the end being clipped off. -

    - -

    uint readBlock(void* buffer, uint size) -
    uint writeBlock(void* buffer, uint size) -
    ulong seek(long offset, SeekPos rel) -
    Overrides of Stream methods. - -
    - -
    -

    std.system

    - -
    - -
    enum Endian -
    Byte order endianness -
    -
    BigEndian -
    big endian byte order -
    LittleEndian -
    little endian byte order -
    -

    -

    Endian endian -
    Native system endianness - -
    - -
    -

    std.thread

    - - The thread module defines the class Thread. - Thread is the basis - for writing multithreaded applications. Each thread - has a unique instance of class Thread associated with it. - It is important to use the Thread class to create and manage - threads as the garbage collector needs to know about all the threads. -

    - -

    -
    typedef ... thread_hdl -
    The type of the thread handle used by the operating system. -

    - -

    class Thread -
    One for each thread. -

    - -

    class ThreadError -
    Thrown for errors. -

    -

    - - The members of Thread are: -

    - -

    - -
    this() -
    Constructor used by classes derived from Thread that - override main(). -

    - -

    this(int (*fp)(void*), void* arg) -
    Constructor used by classes derived from Thread that - override run(). -

    - -

    this(int delegate() dg) -
    Constructor used by classes derived from Thread that - override run(). -

    - -

    thread_hdl hdl; -
    The handle to this thread assigned by the operating system. - This is set to thread_id.init if the thread hasn't been started - yet. -

    - -

    void start(); -
    Create a new thread and start it running. The new thread - initializes itself and then calls run(). - start() can only be called once. -

    - -

    int run(void* p); -
    Entry point for a thread. If not overridden, it calls the - function pointer fp and argument arg passed in - the constructor, or the delegate dg. The return value - is the thread exit code, which is normally 0. -

    - -

    void wait(); -
    Wait for this thread to terminate. - Throws ThreadError - if the thread hasn't begun yet or has already terminated or - is called on itself. -

    - -

    void wait(unsigned milliseconds); -
    Wait for this thread to terminate or until milliseconds time has - elapsed, whichever occurs first. - Throws ThreadError - if the thread hasn't begun yet or has already terminated or - is called on itself. -

    - -

    TS getState(); -
    Returns the state of the thread. - The state is one of the following: -

    - - - - - - -
    TS - Description -
    INITIAL - The thread hasn't been started yet. -
    RUNNING - The thread is running or paused. -
    TERMINATED - The thread has ended. -
    -

    - -

    void setPriority(PRIORITY* p); -
    Adjust the priority of this thread. -

    - - - - - - -
    PRIORITY - Description -
    INCREASE - Increase thread priority -
    DECREASE - Decrease thread priority -
    IDLE - Assign thread low priority -
    CRITICAL - Assign thread high priority -
    -

    - -

    static Thread getThis(); -
    Returns a reference to the Thread for the thread - that called the function. -

    - -

    static Thread[] getAll(); -
    Returns an array of all the threads currently running. -

    - -

    void pause(); -
    Suspend execution of this thread. -

    - -

    void resume(); -
    Resume execution of this thread. -

    - -

    static void pauseAll(); -
    Suspend execution of all threads but this thread. -

    - -

    static void resumeAll(); -
    Resume execution of all paused threads. -

    - -

    static void yield(); -
    Give up the remainder of this thread's time slice. -

    - -

    - -
    -

    std.uri

    - - Encode and decode Uniform Resource Identifiers (URIs). - URIs are used in internet transfer protocols. - Valid URI characters consist of letters, digits, and - the characters ;/?:@&=+$,-_.!~*'(). Escape sequences - consist of '%' followed by two hex digits. - -
    -
    char[] decode(char[] encodedURI) -
    Decodes the URI string encodedURI into a UTF-8 string - and returns it. Escape sequences that resolve to valid URI - characters are not replaced. Escape sequences that resolve - to the '#' character are not replaced. -

    - -

    char[] decodeComponent(char[] encodedURIComponent) -
    Decodes the URI string encodedURI into a UTF-8 string - and returns it. All escape sequences are decoded. -

    - -

    char[] encode(char[] uri) -
    Encodes the UTF-8 string uri into a URI and returns - that URI. Any character not a valid URI character is escaped. - The '#' character is not escaped. -

    - -

    char[] encodeComponent(char[] uriComponent) -
    Encodes the UTF-8 string uri into a URI and returns - that URI. Any character not a letter, digit, or one of - -_.!~*'() is escaped. - -
    - -
    -

    std.utf

    - - Encode and decode UTF-8, UTF-16 and UTF-32 strings. - For more information on UTF-8, see - http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8. -

    - - Note: For Win32 systems, the C wchar_t type - is UTF-16 and corresponds to the D wchar type. - For linux systems, the C wchar_t type - is UTF-32 and corresponds to the D utf.dchar type. -

    - - UTF character support is restricted to (0 <= character <= 0x10FFFF). - -

    -
    class UtfError -
    Exception class that is thrown upon any errors. - The members are: -
    -
    idx -
    Set to the index of the start of the offending UTF sequence. -
    -

    - -

    alias ... dchar -
    An alias for a single UTF-32 character. This may - become a D basic type in the future. -

    - -

    bit isValidDchar(dchar c) -
    Test if c is a valid UTF-32 character. - Returns true if it is, false if not. -

    - -

    dchar decode(char[] s, inout uint idx) -
    dchar decode(wchar[] s, inout uint idx) -
    dchar decode(dchar[] s, inout uint idx) -
    Decodes and returns character starting at s[idx]. - idx is advanced past the decoded character. - If the character is not well formed, a UriError - is thrown and idx remains unchanged. -

    - -

    void encode(inout char[] s, dchar c) -
    void encode(inout wchar[] s, dchar c) -
    void encode(inout dchar[] s, dchar c) -
    Encodes character c and appends it to array s. -

    - -

    void validate(char[] s) -
    void validate(wchar[] s) -
    void validate(dchar[] s) -
    Checks to see if string is well formed or not. - Throws a UtfError if it is not. - Use to check all untrusted input for correctness. -

    - -

    char[] toUTF8(char[] s) -
    char[] toUTF8(wchar[] s) -
    char[] toUTF8(dchar[] s) -
    Encodes string s into UTF-8 and returns the encoded string. -

    - -

    wchar[] toUTF16(char[] s) -
    wchar* toUTF16z(char[] s) -
    wchar[] toUTF16(wchar[] s) -
    wchar[] toUTF16(dchar[] s) -
    Encodes string s into UTF-16 and returns the encoded string. - toUTF16z is suitable for calling the 'W' functions in the - Win32 API that take an LPWSTR or LPCWSTR argument. -

    - -

    dchar[] toUTF32(char[] s) -
    dchar[] toUTF32(wchar[] s) -
    dchar[] toUTF32(dchar[] s) -
    Encodes string s into UTF-32 and returns the encoded string. - -
    - -
    -

    std.zip

    - - Read/write data in the zip archive format. - Makes use of the zlib compression library. - -
    - -
    class ZipException -
    Thrown on error. -

    - -

    class ZipArchive -
    Object representing the entire archive. - ZipArchives are collections of ArchiveMembers. -

    - -

    -
    this() -
    Constructor used when creating a new archive. -

    - -

    void addMember(ArchiveMember de) -
    Add de to the archive. -

    - -

    void deleteMember(ArchiveMember de) -
    Delete de from the archive. -

    - -

    void[] build() -
    Construct an archive out of the current members - of the archive. - Fills in the properties data[], diskNumber, diskStartDir, - numEntries, totalEntries, and directory[]. - For each ArchiveMember, fills in properties - crc32, - compressedSize, compressedData[]. - Return array representing the entire archive. -

    - -

    this(void[] data) -
    Constructor used when reading an existing archive. - data[] is the entire contents of the archive. - Fills in the properties data[], diskNumber, diskStartDir, - numEntries, totalEntries, comment[], and directory[]. - For each ArchiveMember, fills in properties - madeVersion, extractVersion, flags, - compressionMethod, time, - crc32, - compressedSize, - expandedSize, - compressedData[], - diskNumber, - internalAttributes, - externalAttributes, - name[], extra[], comment[]. - Use expand() to get the expanded data for each - ArchiveMember. -

    - -

    ubyte[] expand(ArchiveMember de) -
    Decompress the contents of archive member de - and return the expanded data. - Fills in properties - extractVersion, flags, - compressionMethod, time, - crc32, - compressedSize, - expandedSize, - expandedData[], - name[], extra[]. -

    - -

    ubyte[] data -
    Read Only: array representing the entire contents - of the archive. -

    - -

    uint diskNumber -
    Read Only: 0 since multi-disk zip archives are not supported. -

    - -

    uint diskStartDir -
    Read Only: 0 since multi-disk zip archives are not supported. -

    - -

    uint numEntries -
    Read Only: number of ArchiveMembers in the directory. -

    - -

    uint totalEntries -
    Read Only: same as totalEntries. -

    - -

    char[] comment -
    Read/Write: the archive comment. Must be less than - 65536 bytes in length. -

    - -

    ArchiveMember[char[]] directory -
    Read Only: array indexed by the name of each - member of the archive. - All the members of the archive can be accessed with a foreach - loop: -

    -
    -
    ZipArchive archive = new ZipArchive(data);
    -foreach (ArchiveMember am; archive)
    -{
    -    printf("member name is '%.*s'\n", am.name);
    -}

    -

    -

    - -

    class ArchiveMember -
    A member of the ZipArchive. -

    -

    -
    ushort madeVersion -
    Read Only -

    - -

    ushort extractVersion -
    Read Only -

    - -

    ushort flags -
    Read/Write: normally set to 0 -

    - -

    ushort compressionMethod -
    Read/Write: the only supported values are 0 (no compression) - and 8 (deflate). -

    - -

    date.DosFileTime time -
    Read/Write: Last modified time of the member. - It's in the DOS date/time format. -

    - -

    uint crc32 -
    Read Only: cyclic redundancy check (CRC) value -

    - -

    uint compressedSize -
    Read Only: size of data of member in compressed form. -

    - -

    uint expandedSize -
    Read Only: size of data of member in expanded form. -

    - -

    ushort diskNumber -
    Read Only: should be 0. -

    - -

    ushort internalAttributes -
    Read/Write -

    - -

    uint externalAttributes -
    Read/Write -

    - -

    char[] name -
    Read/Write: Usually the file name of the archive member; - it is used - to index the archive directory for the member. Each - member must have a unique name[]. - Do not change without removing member from the directory - first. -

    - -

    ubyte[] extra -
    Read/Write: extra data for this member. -

    - -

    char[] comment -
    Read/Write: comment associated with this member. -

    - -

    ubyte[] compressedData -
    Read Only: data of member in compressed form. -

    - -

    ubyte[] expandedData -
    Read/Write: data of member in uncompressed form. -
    - -
    - - Bugs: - - -
    -

    std.zlib

    - - Compress / decompress data using the - zlib library. - -
    -
    uint adler32(uint adler, void[] buf) -
    Compute the Adler32 checksum of the data in buf[]. - adler is the starting value when computing a cumulative - checksum. -

    - -

    uint crc32(uint crc, void[] buf) -
    Compute the CRC32 checksum of the data in buf[]. - crc is the starting value when computing a cumulative - checksum. -

    - -

    class ZlibException -
    Thrown in the case of errors occurring in the following: -

    - -

    void[] compress(void[] buf) -
    void[] compress(void[] buf, int level) -
    Compresses the data in buf[] using compression - level level. The default value for level is 6, - legal values are 1..9, with 1 being the least compression and 9 - being the most. Returns the compressed data. -

    - -

    void[] uncompress(void[] buf) -
    void[] uncompress(void[] buf, uint destbufsize) -
    Decompresses the data in buf[]. - destbufsize is the size of the uncompressed data. It - need not be accurate, but the decompression will be faster if - the exact size is supplied. - Returns the decompressed data. -

    - -

    class Compress -
    Used when the data to be compressed is not all in one buffer. -

    - -

    - -
    this() -
    this(int level) -
    Construct. level is the same as for D.zlib.compress(). -

    - -

    void[] compress(void[] buf) -
    Compress the data in buf and return the compressed data. - The buffers returned from successive calls to this should be - concatenated together. -

    - -

    void[] flush() -
    void[] flush(int mode) -
    Compress and return any remaining data. - The returned data should be appended to that returned by compress(). - mode is one of the following: -
    -
    Z_SYNC_FLUSH -
    Syncs up flushing to the next byte boundary. - Used when more data is to be compressed later on. -
    Z_FULL_FLUSH -
    Syncs up flushing to the next byte boundary. - Used when more data is to be compressed later on, - and the decompressor needs to be restartable at this point. -
    Z_FINISH (default) -
    Used when finished compressing the data. -
    - -
    -

    - -

    class UnCompress -
    Used when the data to be decompressed is not all in one buffer. -

    - -

    - -
    this() -
    this(uint destbufsize) -
    Construct. destbufsize is the same as for D.zlib.uncompress(). -

    - -

    void[] uncompress(void[] buf) -
    Decompress the data in buf and return the decompressed data. - The buffers returned from successive calls to this should be - concatenated together. -

    - -

    void[] flush() -
    Decompress and return any remaining data. - The returned data should be appended to that returned by uncompress(). - The UnCompress object cannot be used further. - -
    -
    - -
    -

    std.c.stdio

    - -
    -
    int printf(char* format, ...) -
    C printf() function. -
    - -

    Feedback and Comments

    - - Add feedback and comments regarding this - page. - -
    -Copyright © 1999-2005 by Digital Mars, All Rights Reserved

    - - - - - - - - - - diff -uNr dmd-0.129/dmd/html/d/portability.html dmd-0.130/dmd/html/d/portability.html --- dmd-0.129/dmd/html/d/portability.html 2005-05-19 15:08:50.000000000 +0200 +++ dmd-0.130/dmd/html/d/portability.html 2005-08-26 11:54:10.000000000 +0200 @@ -12,9 +12,15 @@ - - + + + + + + + + + - + D Programming Language - Portability + - - + www.digitalmars.com Home | Search | D +| Comments
    -Last update Thu May 19 2005 +Last update Fri Aug 26 2005


    + + + +
    +
    +
    + + + + + +
    +D
    +Language
    +Phobos
    +Comparisons +
    +
    +Lexical
    Modules
    Declarations
    Types
    Properties
    Attributes
    Pragmas
    Expressions
    Statements
    Arrays
    Structs & Unions
    Classes
    Interfaces
    Enums
    Functions
    Operator Overloading
    Templates
    Mixins
    Contracts
    Conditional Compilation
    Handling errors
    Garbage Collection
    Memory Management
    Floating Point
    Inline Assembler
    Interfacing To C
    Portability Guide
    Embedding D in HTML
    Named Character Entities
    Application Binary Interface
    +
    +
    +

    Portability Guide

    @@ -129,15 +190,15 @@ specific import, and then using that constant in an if statement. +

    Feedback and Comments

    - Add Add feedback and comments regarding this - page. + page.

    -
    -Copyright © 1999-2005 by Digital Mars, All Rights Reserved

    +

    -
    diff -uNr dmd-0.129/dmd/html/d/pragma.html dmd-0.130/dmd/html/d/pragma.html --- dmd-0.129/dmd/html/d/pragma.html 2005-05-19 15:08:50.000000000 +0200 +++ dmd-0.130/dmd/html/d/pragma.html 2005-08-26 11:54:10.000000000 +0200 @@ -12,9 +12,15 @@ - - + + + + + + + + + - + D Programming Language - Pragmas + - - + www.digitalmars.com Home | Search | D +| Comments
    -Last update Thu May 19 2005 +Last update Fri Aug 26 2005
    + + + +
    +
    +
    + + + + + +
    +D
    +Language
    +Phobos
    +Comparisons +
    +
    +Lexical
    Modules
    Declarations
    Types
    Properties
    Attributes
    Pragmas
    Expressions
    Statements
    Arrays
    Structs & Unions
    Classes
    Interfaces
    Enums
    Functions
    Operator Overloading
    Templates
    Mixins
    Contracts
    Conditional Compilation
    Handling errors
    Garbage Collection
    Memory Management
    Floating Point
    Inline Assembler
    Interfacing To C
    Portability Guide
    Embedding D in HTML
    Named Character Entities
    Application Binary Interface
    +
    +
    +

    Pragmas

    -

    -
    -
    
    +	
     	Pragma:
     	    pragma ( Identifier )
     	    pragma ( Identifier , ExpressionList )
    -	

    + Pragmas are a way to pass special information to the compiler @@ -58,9 +117,7 @@ they can influence a statement, a block of statements, a declaration, or a block of declarations. -

    -
    -
    
    +	
     	pragma(ident);		// just by itself
     
     	pragma(ident) declaration; // influence one declaration
    @@ -80,7 +137,7 @@
     	{	statement;
     		statement;
     	}
    -	

    + The kind of pragma it is is determined by the Identifier. ExpressionList is a comma-separated list of @@ -98,19 +155,15 @@

    msg
    Prints a message while compiling, the AssignExpressions must be string literals: -

    -
    -
    
    -	pragma(msg, "compiling...");

    +

    +	pragma(msg, "compiling...");
    lib
    Inserts a directive in the object file to link in the library specified by the AssignExpression. The AssignExpressions must be a string literal: -

    -
    -
    
    -	pragma(lib, "foo.lib");

    +

    +	pragma(lib, "foo.lib");
    @@ -121,34 +174,30 @@ are prefixed by the vendor's trademarked name, in a similar manner to version identifiers: -

    -
    -
    
    +	
     	pragma(DigitalMars_funky_extension) { ... }
    -	

    + Compilers must diagnose an error for unrecognized Pragmas, even if they are vendor specific ones. This implies that vendor specific pragmas should be wrapped in version statements: -

    -
    -
    
    +	
     	version (DigitalMars)
     	{
     	    pragma(DigitalMars_funky_extension) { ... }
     	}
    -	

    + +

    Feedback and Comments

    - Add Add feedback and comments regarding this - page. + page.

    -
    -Copyright © 1999-2005 by Digital Mars, All Rights Reserved

    +

    -
    diff -uNr dmd-0.129/dmd/html/d/pretod.html dmd-0.130/dmd/html/d/pretod.html --- dmd-0.129/dmd/html/d/pretod.html 2005-05-19 15:08:48.000000000 +0200 +++ dmd-0.130/dmd/html/d/pretod.html 2005-08-26 11:54:10.000000000 +0200 @@ -12,9 +12,15 @@ - - + + + + + + + + + - + Digital Mars - The C Preprocessor vs D + - - + www.digitalmars.com Home | Search | D +| Comments
    -Last update Thu May 19 2005 +Last update Fri Aug 26 2005 +
    + + + +
    +
    +
    + + + + + +
    +D
    +Language
    +Phobos
    +Comparisons +

    + +D vs C/C++/C#/Java

    +Rationale for Builtins

    +Converting C to D

    +Converting C++ to D

    +The C Preprocessor vs D

    +D strings vs C++ std::string

    +D complex vs C++ std::complex

    +D Contract Programming vs C++

    +
    +
    +

    The C Preprocessor Versus D

    @@ -79,21 +117,17 @@ fragile syntax for precompiled headers are simply unnecessary and irrelevant to D. -

    -
    -
    
    +	
     	#include <stdio.h>
    -	

    +

    The D Way

    D uses symbolic imports: -

    -
    -
    
    +	
     	import std.c.stdio;
    -	

    +


    #pragma once

    @@ -103,22 +137,18 @@ C header files frequently need to be protected against being #include'd multiple times. To do it, a header file will contain the line: -

    -
    -
    
    +	
     	#pragma once
    -	

    + or the more portable: -

    -
    -
    
    +	
     	#ifndef __STDIO_INCLUDE
     	#define __STDIO_INCLUDE
     	... header file contents
     	#endif
    -	

    +

    The D Way

    @@ -142,15 +172,13 @@ that get mapped onto externally defined data structures, there is a need, and it is handled with: -

    -
    -
    
    +	
     	struct Foo
     	{
     		align (4):	// use 4 byte alignment
     		...
     	}
    -	

    +


    Macros

    @@ -189,53 +217,43 @@

    The C Preprocessor Way

    -

    -
    -
    
    +	
     	#define VALUE	5
    -	

    +

    The D Way

    -

    -
    -
    
    +	
     	const int VALUE = 5;
    -	

    +

  • Creating a list of values or flags:

    The C Preprocessor Way

    -

    -
    -
    
    +	
     	int flags:
     	#define FLAG_X	0x1
     	#define FLAG_Y	0x2
     	#define FLAG_Z	0x4
     	...
     	flags |= FLAG_X;
    -	

    +

    The D Way

    -

    -
    -
    
    +	
     	enum FLAGS { X = 0x1, Y = 0x2, Z = 0x4 };
     	FLAGS flags;
     	...
     	flags |= FLAGS.X;
    -	

    +

  • Distinguishing between ascii chars and wchar chars:

    The C Preprocessor Way

    -

    -
    -
    
    +	
     	#if UNICODE
     	    #define dchar	wchar_t
     	    #define TEXT(s)	L##s
    @@ -246,15 +264,13 @@
     
     	...
     	dchar h[] = TEXT("hello");
    -	

    +

    The D Way

    -

    -
    -
    
    +	
     	dchar[] h = "hello";
    -	

    + D's optimizer will inline the function, and will do the conversion of the @@ -265,16 +281,14 @@

    The C Preprocessor Way

    -

    -
    -
    
    +	
     	#if PROTOTYPES
     	#define P(p)	p
     	#else
     	#define P(p)	()
     	#endif
     	int func P((int x, int y));
    -	

    +

    The D Way

    @@ -285,41 +299,33 @@

    The C Preprocessor Way

    -

    -
    -
    
    +	
     	#define INT 	int
    -	

    +

    The D Way

    -

    -
    -
    
    +	
     	alias int INT;
    -	

    +

  • Using one header file for both declaration and definition:

    The C Preprocessor Way

    -

    -
    -
    
    +	
     	#define EXTERN extern
     	#include "declations.h"
     	#undef EXTERN
     	#define EXTERN
     	#include "declations.h"
    -	

    + In declarations.h: -

    -
    -
    
    +	
     	EXTERN int foo;
    -	

    +

    The D Way

    @@ -332,19 +338,15 @@

    The C Preprocessor Way

    -

    -
    -
    
    +	
     	#define X(i)	((i) = (i) / 3)
    -	

    +

    The D Way

    -

    -
    -
    
    +	
     	int X(inout int i) { return i = i / 3; }
    -	

    + The compiler optimizer will inline it; no efficiency is lost. @@ -352,11 +354,9 @@

    The C Preprocessor Way

    -

    -
    -
    
    +	
     	#define assert(e)	((e) || _assert(__LINE__, __FILE__))
    -	

    +

    The D Way

    @@ -368,9 +368,7 @@

    The C Preprocessor Way

    -

    -
    -
    
    +	
     	#ifndef _CRTAPI1
     	#define _CRTAPI1 __cdecl
     	#endif
    @@ -379,32 +377,28 @@
     	#endif
     
     	int _CRTAPI2 func();
    -	

    +

    The D Way

    Calling conventions can be specified in blocks, so there's no need to change it for every function: -

    -
    -
    
    +	
     	extern (Windows)
     	{
     	    int onefunc();
     	    int anotherfunc();
     	}
    -	

    +

  • Hiding __near or __far pointer wierdness:

    The C Preprocessor Way

    -

    -
    -
    
    +	
     	#define LPSTR	char FAR *
    -	

    +

    The D Way

    @@ -418,9 +412,7 @@ Selecting which function to use based on text substitution: -

    -
    -
    
    +	
     	#ifdef UNICODE
     	int getValueW(wchar_t *p);
     	#define getValue getValueW
    @@ -428,16 +420,14 @@
     	int getValueA(char *p);
     	#define getValue getValueA
     	#endif
    -	

    +

    The D Way

    D enables declarations of symbols that are aliases of other symbols: -

    -
    -
    
    +	
     	version (UNICODE)
     	{
     	    int getValueW(wchar[] p);
    @@ -448,7 +438,7 @@
     	    int getValueA(char[] p);
     	    alias getValueA getValue;
     	}
    -	

    +


    @@ -508,9 +498,7 @@ function, so it is implemented as a macro. For example, consider this fragment from a byte code interpreter: -

    -
    -
    
    +	
     	unsigned char *ip;	// byte code instruction pointer
     	int *stack;
     	int spi;		// stack pointer
    @@ -532,7 +520,7 @@
     		...
     	    }
     	}
    -	

    + This suffers from numerous problems:

      @@ -552,9 +540,7 @@ D neatly addresses this with nested functions: -

      -
      -
      
      +	
       	ubyte* ip;		// byte code instruction pointer
       	int[] stack;		// operand stack
       	int spi;		// stack pointer
      @@ -577,7 +563,7 @@
       		...
       	    }
       	}
      -	

      + The problems addressed are:

        @@ -604,15 +590,13 @@ The first way is to use the #error preprocessing directive: -

        -
        -
        
        +	
         	#if FOO || BAR
         	    ... code to compile ...
         	#else
         	#error "there must be either FOO or BAR"
         	#endif
        -	

        + This has the limitations inherent in preprocessor expressions (i.e. integer constant expressions only, no casts, no sizeof, @@ -622,23 +606,19 @@ These problems can be circumvented to some extent by defining a static_assert macro (thanks to M. Wilson): -

        -
        -
        
        +	
         	#define static_assert(_x) do { typedef int ai[(_x) ? 1 : 0]; } while(0)
        -	

        + and using it like: -

        -
        -
        
        +	
         	void foo(T t)
         	{
         	    static_assert(sizeof(T) < 4);
         	    ...
         	}
        -	

        + This works by causing a compile time semantic error if the condition evaluates @@ -652,9 +632,7 @@ which can be used anywhere a declaration or a statement can be used. For example: -

        -
        -
        
        +	
         	version (FOO)
         	{
         	    class Bar
        @@ -677,7 +655,7 @@
         	{
         	    static assert(0);	// unsupported version
         	}
        -	

        +


        Mixins

        @@ -728,15 +706,15 @@
      +
  • Feedback and Comments

    - Add Add feedback and comments regarding this - page. + page.

    -
    -Copyright © 1999-2005 by Digital Mars, All Rights Reserved

    +

    -
    diff -uNr dmd-0.129/dmd/html/d/property.html dmd-0.130/dmd/html/d/property.html --- dmd-0.129/dmd/html/d/property.html 2005-05-19 15:08:50.000000000 +0200 +++ dmd-0.130/dmd/html/d/property.html 2005-08-26 11:54:10.000000000 +0200 @@ -12,9 +12,15 @@ - - + + + + + + + + + - + D Programming Language - Properties + - - + www.digitalmars.com Home | Search | D +| Comments
    -Last update Thu May 19 2005 +Last update Fri Aug 26 2005
    + + + +
    +
    +
    + + + + + +
    +D
    +Language
    +Phobos
    +Comparisons +
    +
    +Lexical
    Modules
    Declarations
    Types
    Properties
    Attributes
    Pragmas
    Expressions
    Statements
    Arrays
    Structs & Unions
    Classes
    Interfaces
    Enums
    Functions
    Operator Overloading
    Templates
    Mixins
    Contracts
    Conditional Compilation
    Handling errors
    Garbage Collection
    Memory Management
    Floating Point
    Inline Assembler
    Interfacing To C
    Portability Guide
    Embedding D in HTML
    Named Character Entities
    Application Binary Interface
    +
    +
    +

    Properties

    @@ -91,9 +152,7 @@ default initializer for that variable or field. For example: -

    -
    -
    
    +	
     	int a;
     	int b = 1;
     	typedef int t = 2;
    @@ -115,7 +174,7 @@
      
     	Foo.a.init	// is 0
     	Foo.b.init	// is 7
    -	

    +

    Class and Struct Properties

    @@ -128,9 +187,7 @@ A simple property would be: -

    -
    -
    
    +	
     	struct Foo
     	{
     	    int data() { return m_data; }	// read property
    @@ -140,13 +197,11 @@
     	  private:
     	    int m_data;
     	}
    -	

    + To use it: -

    -
    -
    
    +	
     	int test()
     	{
     	    Foo f;
    @@ -154,7 +209,7 @@
     	    f.data = 3;		// same as f.data(3);
     	    return f.data + 3;	// same as return f.data() + 3;
     	}
    -	

    + The absence of a read method means that the property is write-only. The absence of a write method means that the property is read-only. @@ -170,15 +225,15 @@ Note: Properties currently cannot be the lvalue of an op=, ++, or -- operator. +

    Feedback and Comments

    - Add Add feedback and comments regarding this - page. + page.

    -
    -Copyright © 1999-2005 by Digital Mars, All Rights Reserved

    +

    -
    diff -uNr dmd-0.129/dmd/html/d/rationale.html dmd-0.130/dmd/html/d/rationale.html --- dmd-0.129/dmd/html/d/rationale.html 2005-06-25 01:42:16.000000000 +0200 +++ dmd-0.130/dmd/html/d/rationale.html 2005-08-26 11:54:10.000000000 +0200 @@ -12,9 +12,15 @@ - - + + + + + + + + + - + Digital Mars - The D Programming Language - Rationale + - - + www.digitalmars.com Home | Search | D +| Comments
    -Last update Sat Jun 25 2005 +Last update Fri Aug 26 2005

    Rationale

    @@ -61,15 +69,13 @@ Overloading operator/() also provides no symmetric way, as a member function, to overload the reverse operation. For example, -

    -
    -
    
    +	
     	class A
     	{
     	    int operator/(int i);	// overloads (a+i)
     	    static operator/(int i, A a)	// overloads (i+a)
     	}
    -	

    + The second overload does the reverse overload, but it cannot be virtual, and so has a confusing asymmetry with @@ -85,25 +91,21 @@ when the operands are objects of different types: -

    -
    -
    
    +	
     	class A { }
     	class B { }
     	int add(class A, class B);
    -	

    + Should add() be in class A or B? The obvious stylistic solution would be to put it in the class of the first operand, -

    -
    -
    
    +	
     	class A
     	{
     	    int add(class B) { }
     	}
    -	

    +

  • Operator overloads usually need access to private members of a class, and making them global breaks the object oriented @@ -192,17 +194,13 @@ To illustrate, if either op1 or op2 or both are NaN, then: -

    -
    -
    
    +	
     	    (op1 < op2)
    -	

    + does not yield the same result as: -

    -
    -
    
    +	
     	    !(op1 >= op2)
    -	

    + if the NaNs are done correctly.

    Why use static if(0) rather than if (0)?

    @@ -213,68 +211,57 @@
  • if (0) introduces a new scope, static if(...) does not. Why does this matter? It matters if one wants to conditionally declare a new variable: -

    -
    -
    
    +	
     	static if (...) int x; else long x;
     	x = 3;
    -	

    + whereas: -

    -
    -
    
    +	
     	if (...) int x; else long x;
     	x = 3;    // error, x is not defined
    -	

    +

  • False static if conditionals don't have to semantically work. For example, it may depend on a conditionally compiled declaration somewhere else: -

    -
    -
    
    +	
     	static if (...) int x;
     	int test()
     	{
     	    static if (...) return x;
     	    else return 0;
     	}
    -	

    +

  • Static if's can appear where only declarations are allowed: -

    -
    -
    
    +	
     	class Foo
     	{
     		static if (...)
     		    int x;
     	}
    -	

    +

  • Static if's can declare new type aliases: -

    -
    -
    
    +	
     	static if (0 || is(int T)) T x;
    -	

    +

    Feedback and Comments

    - Add Add feedback and comments regarding this - page. + page.

    -
    -Copyright © 1999-2005 by Digital Mars, All Rights Reserved

    +

    -
    diff -uNr dmd-0.129/dmd/html/d/statement.html dmd-0.130/dmd/html/d/statement.html --- dmd-0.129/dmd/html/d/statement.html 2005-06-01 14:50:06.000000000 +0200 +++ dmd-0.130/dmd/html/d/statement.html 2005-08-26 11:54:10.000000000 +0200 @@ -12,9 +12,15 @@ - - + + + + + + + + + - + D Programming Language - Statements + - - + www.digitalmars.com Home | Search | D +| Comments
    -Last update Wed Jun 01 2005 +Last update Fri Aug 26 2005 +
    + + + +
    +
    +
    + + + + + +
    +D
    +Language
    +Phobos
    +Comparisons +

    +Lexical
    Modules
    Declarations
    Types
    Properties
    Attributes
    Pragmas
    Expressions
    Statements
    Arrays
    Structs & Unions
    Classes
    Interfaces
    Enums
    Functions
    Operator Overloading
    Templates
    Mixins
    Contracts
    Conditional Compilation
    Handling errors
    Garbage Collection
    Memory Management
    Floating Point
    Inline Assembler
    Interfacing To C
    Portability Guide
    Embedding D in HTML
    Named Character Entities
    Application Binary Interface
    +
    +
    +

    Statements

    @@ -46,9 +107,7 @@ C and C++ programmers will find the D statements very familiar, with a few interesting additions. -

    -
    -
    
    +
     	Statement:
     		LabeledStatement
     		BlockStatement
    @@ -75,19 +134,17 @@
     		VolatileStatement
     		AsmStatement
     		PragmaStatement
    -

    +

    Labelled Statements

    Statements can be labelled. A label is an identifier that precedes a statement. -

    -
    -
    
    +	
     	LabelledStatement:
     		Identifier ':' Statement
    -	

    + Any statement can be labelled, including empty statements, and so can serve as the target @@ -108,9 +165,7 @@ A block statement is a sequence of statements enclosed by { }. The statements are executed in lexical order. -

    -
    -
    
    +	
     	BlockStatement:
     		{ }
     		{ StatementList }
    @@ -118,15 +173,13 @@
     	StatementList:
     		Statement
     		Statement StatementList
    -	

    + A block statement introduces a new scope for local symbols. A local symbol's name, however, must be unique within the function. -

    -
    -
    
    +	
     	void func1(int x)
     	{   int x;	// illegal, x is multiply defined in function scope
     	}
    @@ -154,7 +207,7 @@
     	    {	x++;	// illegal, x is undefined
     	    }
     	}
    -	

    + The idea is to avoid bugs in complex functions caused by scoped declarations inadvertantly hiding previous ones. @@ -164,12 +217,10 @@ The expression is evaluated. -

    -
    -
    
    +	
     	ExpressionStatement:
     		Expression ;
    -	

    + Expressions that have no effect, like (x + x), are illegal in expression statements. @@ -178,9 +229,7 @@ Declaration statements declare and initialize variables. -

    -
    -
    
    +	
     	DeclarationStatement:
     		Type IdentifierList ;
     
    @@ -191,7 +240,7 @@
     	Variable:
     		Identifier
     		Identifier = Initializer
    -	

    + If no Initializer is there to initialize the variable, it is initialized to the default value for its type. @@ -200,13 +249,11 @@ If statements provide simple conditional execution of statements. -

    -
    -
    
    +	
     	IfStatement:
     		if ( Expression ) Statement
     		if ( Expression ) Statement else Statement
    -	

    + Expression is evaluated and must have a type that can be converted to a boolean. If it's true the if @@ -221,12 +268,10 @@ While statements implement simple loops. -

    -
    -
    
    +	
     	WhileStatement:
     		while ( Expression ) Statement
    -	

    + Expression is evaluated and must have a type that can be converted to a boolean. If it's true the @@ -243,12 +288,10 @@ Do-While statements implement simple loops. -

    -
    -
    
    +	
     	DoStatement:
     		do Statement  while ( Expression )
    -	

    + Statement is executed. Then Expression is evaluated and must have a type that @@ -266,9 +309,7 @@ For statements implement loops with initialization, test, and increment clauses. -

    -
    -
    
    +	
     	ForStatement:
     		for (Initialize; Test; Increment) Statement
     
    @@ -284,7 +325,7 @@
     	Increment:
     		empty
     		Expression
    -	

    + Initializer is executed. Test is evaluated and must have a type that @@ -303,42 +344,34 @@ If Initializer declares a variable, that variable's scope extends through the end of Statement. For example: -

    -
    -
    
    +	
     	for (int i = 0; i < 10; i++)
     		foo(i);
    -	

    + is equivalent to: -

    -
    -
    
    +	
     	{   int i;
     	    for (i = 0; i < 10; i++)
     		foo(i);
     	}
    -	

    + Function bodies cannot be empty: -

    -
    -
    
    +	
     	for (int i = 0; i < 10; i++)
     		;	// illegal
    -	

    + Use instead: -

    -
    -
    
    +	
     	for (int i = 0; i < 10; i++)
     	{
     	}
    -	

    + The Initializer may be omitted. Test may also be omitted, and if so, it is treated as if it evaluated to true. @@ -347,9 +380,7 @@ A foreach statement loops over the contents of an aggregate. -

    -
    -
    
    +	
     	ForeachStatement:
     		foreach (ForeachTypeList; Expression) Statement
     
    @@ -360,7 +391,7 @@
     	ForeachType:
     		inout Type Identifier
     		Type Identifier
    -	

    + Expression is evaluated. It must evaluate to an aggregate expression @@ -387,16 +418,14 @@ must be of int or uint type, it cannot be inout, and it is set to be the index of the array element. -

    -
    -
    
    +	
     	char[] a;
     	...
     	foreach (int i, char c; a)
     	{
     	    printf("a[%d] = '%c'\n", i, c);
     	}
    -	

    + If the aggregate expression is a static or dynamic array of chars, wchars, or dchars, then the Type of @@ -405,9 +434,7 @@ In this manner any UTF array can be decoded into any UTF type: -

    -
    -
    
    +	
     	char[] a = "\xE2\x89\xA0";	// \u2260 encoded as 3 UTF-8 bytes
     
     	foreach (dchar c; a)
    @@ -421,7 +448,7 @@
     	{
     	    printf("%x, ", c);	// prints 'e2, 89, a0'
     	}
    -	

    + If the aggregate expression is an associative array, there @@ -435,16 +462,14 @@ array. It cannot be inout, and it is set to be the index of the array element. -

    -
    -
    
    +	
     	double[char[]] a;	// index type is char[], value type is double
     	...
     	foreach (char[] s, double d; a)
     	{
     	    printf("a['%.*s'] = %g\n", s, d);
     	}
    -	

    + If the aggregate expression is a static or dynamic array, the elements are iterated over starting at index 0 and continuing @@ -456,11 +481,9 @@ If the aggregate is a struct or a class object, that struct or class must have an opApply function with the type: -

    -
    -
    
    +	
     	int opApply(int delegate(inout Type [, ...]) dg);
    -	

    + where Type matches the Type used in the foreach declaration of Identifier. Multiple ForeachTypes @@ -480,9 +503,7 @@ For example, consider a class that is a container for two elements: -

    -
    -
    
    +	
     	class Foo
     	{
     	    uint array[2];
    @@ -499,13 +520,11 @@
     		return result;
     	    }
     	}
    -	

    + An example using this might be: -

    -
    -
    
    +	
     	void test()
     	{
     	    Foo a = new Foo();
    @@ -518,7 +537,7 @@
     		printf("%d\n", u);
     	    }
     	}
    -	

    + which would print: @@ -530,9 +549,7 @@ Aggregates can be string literals, which can be accessed as char, wchar, or dchar arrays: -

    -
    -
    
    +	
     	void test()
     	{
     	    foreach (char c; "ab")
    @@ -544,7 +561,7 @@
     		wprintf("'%c'\n", w);
     	    }
     	}
    -	

    + which would print: @@ -557,9 +574,7 @@ inout can be used to update the original elements: -

    -
    -
    
    +	
     	void test()
     	{
     	    static uint[2] a = [7, 8];
    @@ -573,7 +588,7 @@
     		printf("%d\n", u);
     	    }
     	}
    -	

    + which would print: @@ -588,9 +603,7 @@ reassigned or destructed while the foreach is iterating over the elements. -

    -
    -
    
    +	
     	int[] a;
     	int[] b;
     	foreach (int i; a)
    @@ -600,7 +613,7 @@
     	    a = b;		// error
     	}
     	a = null;		// ok
    -	

    + A BreakStatement in the body of the foreach will exit the foreach, a ContinueStatement will immediately start the @@ -612,9 +625,7 @@ statements depending on the value of the switch expression. -

    -
    -
    
    +	
     	SwitchStatement:
     		switch ( Expression ) BlockStatement
     
    @@ -623,7 +634,7 @@
     
     	DefaultStatement:
     		default: Statement
    -	

    + Expression is evaluated. The result type T must be of integral type or char[] or wchar[]. The result is @@ -659,9 +670,7 @@ can be nested within block statements; they do not have to be in the outermost block. For example, this is allowed: -

    -
    -
    
    +	
     	switch (i)
     	{
     	    case 1:
    @@ -670,15 +679,13 @@
     	    }
     		break;
     	}
    -	

    + Like in C and C++, case statements 'fall through' to subsequent case values. A break statement will exit the switch BlockStatement. For example: -

    -
    -
    
    +	
     	switch (i)
     	{
     	    case 1:
    @@ -691,7 +698,7 @@
     		x = 5;
     		break;
     	}
    -	

    + will set x to 4 if i is 1.

    @@ -699,9 +706,7 @@ Note: Unlike C and C++, strings can be used in switch expressions. For example: -

    -
    -
    
    +	
     	char[] name;
     	...
     	switch (name)
    @@ -710,7 +715,7 @@
     	    case "sally":
     		...
     	}
    -	

    + For applications like command line switch processing, this can lead to much more straightforward code, being clearer and @@ -730,13 +735,11 @@ A continue aborts the current iteration of its enclosing loop statement, and starts the next iteration. -

    -
    -
    
    +	
     	ContinueStatement:
     		continue;
     		continue Identifier ;
    -	

    + continue executes the next iteration of its innermost enclosing while, for, or do loop. The increment clause is executed. @@ -761,13 +764,11 @@ A break exits the enclosing statement. -

    -
    -
    
    +	
     	BreakStatement:
     		break;
     		break Identifier ;
    -	

    + break exits the innermost enclosing while, for, do, or switch statement, resuming execution at the statement following it. @@ -792,13 +793,11 @@ A return exits the current function and supplies its return value. -

    -
    -
    
    +	
     	ReturnStatement:
     		return;
     		return Expression ;
    -	

    + Expression is required if the function specifies a return type that is not void. @@ -834,15 +833,13 @@ A goto transfers to the statement labelled with Identifier. -

    -
    -
    
    +	
     	GotoStatement:
     		goto Identifier ;
     		goto default ;
     		goto case ;
     		goto case Expression ;
    -	

    + The second form, goto default;, transfers to the innermost DefaultStatement of an enclosing SwitchStatement. @@ -869,42 +866,36 @@ The with statement is a way to simplify repeated references to the same object. -