diff -uNr dmd-0.125/dmd/html/d/abi.html dmd-0.126/dmd/html/d/abi.html --- dmd-0.125/dmd/html/d/abi.html 2005-05-19 11:44:48.000000000 +0200 +++ dmd-0.126/dmd/html/d/abi.html 2005-05-19 15:08:50.000000000 +0200 @@ -28,7 +28,7 @@ D Programming Language - Application Binary Interface - + www.digitalmars.com @@ -206,6 +206,20 @@
Copyright © 1999-2005 by Digital Mars, All Rights Reserved

+ + + + + diff -uNr dmd-0.125/dmd/html/d/acknowledgements.html dmd-0.126/dmd/html/d/acknowledgements.html --- dmd-0.125/dmd/html/d/acknowledgements.html 2005-05-19 11:44:48.000000000 +0200 +++ dmd-0.126/dmd/html/d/acknowledgements.html 2005-05-19 15:08:50.000000000 +0200 @@ -28,7 +28,7 @@ D Programming Language - Acknowledgements - + www.digitalmars.com @@ -82,6 +82,20 @@


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

+ + + + + diff -uNr dmd-0.125/dmd/html/d/arrays.html dmd-0.126/dmd/html/d/arrays.html --- dmd-0.125/dmd/html/d/arrays.html 2005-05-19 11:44:48.000000000 +0200 +++ dmd-0.126/dmd/html/d/arrays.html 2005-06-02 01:51:26.000000000 +0200 @@ -28,7 +28,7 @@ D Programming Language - Arrays - + www.digitalmars.com @@ -37,7 +37,7 @@ | D
-Last update Thu May 19 2005 +Last update Thu Jun 02 2005


@@ -722,6 +722,7 @@

Array Initialization

+

Default Initialization

+

Void Initialization

+ + Void initialization happens when the Initializer for + an array is void. What it means is that no initialization + is done, i.e. the contents of the array will be undefined. + This is most useful as an efficiency optimization. + Void initializations are an advanced technique and should only be used + when profiling indicates that it matters. +

Static Initialization of Static Arrays

@@ -966,18 +976,14 @@

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


-	delete b["hello"];
+	b.remove("hello");
 	

- This confusingly appears to delete the value of b["hello"], but - does not, it removes the key "hello" from the associative array. -

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


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

+ + + + + diff -uNr dmd-0.125/dmd/html/d/attribute.html dmd-0.126/dmd/html/d/attribute.html --- dmd-0.125/dmd/html/d/attribute.html 2005-05-19 11:44:48.000000000 +0200 +++ dmd-0.126/dmd/html/d/attribute.html 2005-05-19 15:08:50.000000000 +0200 @@ -28,7 +28,7 @@ D Programming Language - Attributes - + www.digitalmars.com @@ -476,6 +476,20 @@


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

+ + + + + diff -uNr dmd-0.125/dmd/html/d/changelog.html dmd-0.126/dmd/html/d/changelog.html --- dmd-0.125/dmd/html/d/changelog.html 2005-05-20 15:43:00.000000000 +0200 +++ dmd-0.126/dmd/html/d/changelog.html 2005-06-07 21:54:28.000000000 +0200 @@ -1,2184 +1,2260 @@ - - - - - - - - - - - - - - - - - - - - - -D Programming Language - Change Log - - - - -www.digitalmars.com - -Home -| Search -| D - -
-Last update Fri May 20 2005 -


- - -

D Change Log

- - - - -
-

- What's New for - D 0.125 -

- -May 20, 2005 -

- -

New/Changed Features

- - -

Bugs Fixed

- - -
-

- What's New for - D 0.124 -

- -May 19, 2005 -

- -

New/Changed Features

- - -

Bugs Fixed

- - -
-

- What's New for - D 0.123 -

- -May 11, 2005 -

- -

New/Changed Features

- - -

Bugs Fixed

- - -
-

- What's New for - D 0.122 -

- -May 3, 2005 -

- -

New/Changed Features

- - -

Bugs Fixed

- - -
-

- What's New for - D 0.121 -

- -Apr 15, 2005 -

- -

New/Changed Features

- - -

Bugs Fixed

- - -
-

- What's New for - D 0.120 -

- -Apr 6, 2005 -

- -

New/Changed Features

- - -

Bugs Fixed

- - -
-

- What's New for - D 0.119 -

- -Mar 18, 2005 -

- -

New/Changed Features

- - -

Bugs Fixed

- - -
-

- What's New for - D 0.118 -

- -Mar 12, 2005 -

- -

Bugs Fixed

- - -
-

- What's New for - D 0.117 -

- -Mar 10, 2005 -

- -

New/Changed Features

- - -

Bugs Fixed

- - -
-

- What's New for - D 0.116 -

- -Mar 7, 2005 -

- -

New/Changed Features

- - -

Bugs Fixed

- - -
-

- What's New for - D 0.115 -

- -Feb 28, 2005 -

- -

Bugs Fixed

- - -
-

- What's New for - D 0.114 -

- -Feb 27, 2005 -

- -

New/Changed Features

- - -

Bugs Fixed

- - -
-

- What's New for - D 0.113 -

- -Feb 12, 2005 -

- -

New/Changed Features

- - -

Bugs Fixed

- - -
-

- What's New for - D 0.112 -

- -Jan 26, 2005 -

- -Note: This is a library only change, the dmd executables are still -at 0.111. - -

New/Changed Features

- - -
-

- What's New for - D 0.111 -

- -Jan 15, 2005 - -

New/Changed Features

- - -

Bugs Fixed

- - -
-

- What's New for - D 0.110 -

- -Dec 30, 2004 - -

New/Changed Features

- - -

Bugs Fixed

- - -
-

- What's New for - D 0.109 -

- -Dec 5, 2004 - -

New/Changed Features

- - -

Bugs Fixed

- - -
-

- What's New for - D 0.108 -

- -Nov 30, 2004 - -

Bugs Fixed

- - -
-

- What's New for - D 0.107 -

- -Nov 29, 2004 - -

New/Changed Features

- - -

Bugs Fixed

- - -
-

- What's New for - D 0.106 -

- -Nov 9, 2004 - -

New/Changed Features

- - -

Bugs Fixed

- - -
-

- What's New for - D 0.105 -

- -Oct 28, 2004 - -

New/Changed Features

- - -

Bugs Fixed

- - -
-

- What's New for - D 0.104 -

- -Oct 21, 2004 - -

Bugs Fixed

- - -
-

What's New for D 0.103

- -Oct 20, 2004 - -

New/Changed Features

- - -

Bugs Fixed

- - -
-

What's New for D 0.102

- -Sep 20, 2004 - -

New/Changed Features

- - -

Bugs Fixed

- - -
-

What's New for D 0.101

- -Aug 30, 2004 - -

New/Changed Features

- - -

Bugs Fixed

- - -
-

What's New for D 0.100

- -Aug 20, 2004 - -

Bugs Fixed

- - -
-

What's New for D 0.99

- -Aug 19, 2004 - -

New/Changed Features

- - -

Bugs Fixed

- - -
-

What's New for D 0.98

- -Aug 5, 2004 - -

New/Changed Features

- - -

Bugs Fixed

- - -
-

What's New for D 0.97

- -Jul 26, 2004 - -

New/Changed Features

- - -

Bugs Fixed

- - -
-

What's New for D 0.96

- -Jul 21, 2004 - -

New/Changed Features

- - -

Bugs Fixed

- - -
-

What's New for D 0.95

- -Jul 6, 2004 - -

New/Changed Features

- - -

Bugs Fixed

- - -
-

What's New for D 0.94

- -Jun 27, 2004 - -

Bugs Fixed

- - -
-

What's New for D 0.93

- -Jun 22, 2004 - -

New/Changed Features

- - -

Bugs Fixed

- - -
-

What's New for D 0.92

- -Jun 7, 2004 - -

New/Changed Features

- - -

Bugs Fixed

- - -
-

What's New for D 0.91

- -May 27, 2004 - -

New/Changed Features

- - -

Bugs Fixed

- - -
-

What's New for D 0.90

- -May 20, 2004 - -

Bugs Fixed

- - -
-

What's New for D 0.89

- -May 17, 2004 - -

New/Changed Features

- - -

Bugs Fixed

- - -
-

What's New for D 0.88

- -May 5, 2004 - -

New/Changed Features

- - -

Bugs Fixed

- - -
-

What's New for D 0.86

- -Apr 23, 2004 - -

New/Changed Features

- - -

Bugs Fixed

- - -
-

What's New for D 0.82

- -Mar 28, 2004 - -

Bugs Fixed

- - -
-

What's New for D 0.81

- -Mar 7, 2004 - -

Bugs Fixed

- - -
-

What's New for D 0.80

- -Mar 5, 2004 - -

New/Changed Features

- - -

Bugs Fixed

- - -
-

What's New for D 0.79

- -Feb 2, 2004 - -

New/Changed Features

- - -

Bugs Fixed

- - -
-

What's New for D 0.78

- -Jan 14, 2004 - -

New/Changed Features

- - -

Bugs Fixed

- - -
-

What's New for D 0.77

- -Jan 2, 2004 - -

New/Changed Features

- - -

Bugs Fixed

- - -
-

What's New for D 0.76

- -Nov 21, 2003 - -

New/Changed Features

- - -

Bugs Fixed

- - -
-

What's New for D 0.75

- -Nov 4, 2003 - -

New/Changed Features

- - -
-

What's New for D 0.74

- -Oct 15, 2003 - -

New/Changed Features

- - -

Bugs Fixed

- - -
-

What's New for D 0.73

- -Sep 18, 2003 - -

New/Changed Features

- - -

Bugs Fixed

- - -
-

What's New for D 0.72

- -Sep 14, 2003 - -

New/Changed Features

- - -

Bugs Fixed

- - -

Linux Bugs Fixed

- - -
-

What's New for D 0.71

- -Sep 3, 2003 - -

New/Changed Features

- - -

Bugs Fixed

- - -
-

What's New for D 0.70

- -Aug 24, 2003 - -

New/Changed Features

- - -

Bugs Fixed

- - -
-

What's New for D 0.69

- -Aug 11, 2003 - -

New/Changed Features

- - -

Bugs Fixed

- - -
-

What's New for D 0.68

- -Jul 8, 2003 - - - -
-

What's New for D 0.67

- -Jun 17, 2003 - - - -
-

What's New for D 0.66

- -Jun 8, 2003 - - - -
-

What's New for D 0.65

- -May 13, 2003 - -

linux version

- - - -
-

What's New for D 0.64

- -May 12, 2003 - -

linux version

- - - -
-

What's New for D 0.63

- -May 10, 2003 - - - -
-

What's New for D 0.61

- -Mar 30, 2003 - - - -
-

What's New for D 0.59

- -Mar 6, 2003 - - - -
-

What's New for D 0.58

- -Mar 3, 2003 - - - -
-

What's New for D 0.57

- -Feb 25, 2003 - - - -Many thanks to Burton Radons for his help with this. - -
-

What's New for D 0.56

- -Feb 20, 2003 - - - -
-

What's New for D 0.55

- -Feb 17, 2003 - - - -
-

What's New for D 0.54

- -Feb 14, 2003 - - - - These changes have been needed for a while, and it's time to - put them in before D gets too constrained by legacy code. - Fortunately, using grep and global/search/replace can easily - take care of the type renames. - The array declaration issue can be fixed - by grepping for "][", and then manually fixing each. - - -
-

What's New for D 0.53

- -Feb 8, 2003 - - - - -
-

What's New for D 0.52

- -Feb 5, 2003 - - - - -
-

What's New for D 0.51

- -Jan 27, 2003 - - - - -
-

What's New for D 0.50

- -Nov 20, 2002 - - - - -
-

What's New for D 0.49

- -Nov 18, 2002 - - - - -
-

What's New for D 0.48

- -Oct 25, 2002 - - - - -
-

What's New for D 0.46

- -Oct 22, 2002 - - - - -
-

What's New for D 0.45

- -Oct 8, 2002 - - - - -
-

What's New for D 0.44

- -Oct 1, 2002 - - - - -
-

What's New for D 0.43

- -Sep 28, 2002 - - - -

Feedback and Comments

- - Add feedback and comments regarding this - page. - -
-Copyright © 1999-2005 by Digital Mars, All Rights Reserved

- - - - - - + + + + + + + + + + + + + + + + + + + + + +D Programming Language - Change Log + + + + +www.digitalmars.com + +Home +| Search +| D + +
+Last update Tue Jun 07 2005 +


+ + +

D Change Log

+ + + + +
+

+ What's New for + D 0.126 +

+ +Jun 7, 2005 +

+ +

New/Changed Features

+ + +

Bugs Fixed

+ + +
+

+ What's New for + D 0.125 +

+ +May 20, 2005 +

+ +

New/Changed Features

+ + +

Bugs Fixed

+ + +
+

+ What's New for + D 0.124 +

+ +May 19, 2005 +

+ +

New/Changed Features

+ + +

Bugs Fixed

+ + +
+

+ What's New for + D 0.123 +

+ +May 11, 2005 +

+ +

New/Changed Features

+ + +

Bugs Fixed

+ + +
+

+ What's New for + D 0.122 +

+ +May 3, 2005 +

+ +

New/Changed Features

+ + +

Bugs Fixed

+ + +
+

+ What's New for + D 0.121 +

+ +Apr 15, 2005 +

+ +

New/Changed Features

+ + +

Bugs Fixed

+ + +
+

+ What's New for + D 0.120 +

+ +Apr 6, 2005 +

+ +

New/Changed Features

+ + +

Bugs Fixed

+ + +
+

+ What's New for + D 0.119 +

+ +Mar 18, 2005 +

+ +

New/Changed Features

+ + +

Bugs Fixed

+ + +
+

+ What's New for + D 0.118 +

+ +Mar 12, 2005 +

+ +

Bugs Fixed

+ + +
+

+ What's New for + D 0.117 +

+ +Mar 10, 2005 +

+ +

New/Changed Features

+ + +

Bugs Fixed

+ + +
+

+ What's New for + D 0.116 +

+ +Mar 7, 2005 +

+ +

New/Changed Features

+ + +

Bugs Fixed

+ + +
+

+ What's New for + D 0.115 +

+ +Feb 28, 2005 +

+ +

Bugs Fixed

+ + +
+

+ What's New for + D 0.114 +

+ +Feb 27, 2005 +

+ +

New/Changed Features

+ + +

Bugs Fixed

+ + +
+

+ What's New for + D 0.113 +

+ +Feb 12, 2005 +

+ +

New/Changed Features

+ + +

Bugs Fixed

+ + +
+

+ What's New for + D 0.112 +

+ +Jan 26, 2005 +

+ +Note: This is a library only change, the dmd executables are still +at 0.111. + +

New/Changed Features

+ + +
+

+ What's New for + D 0.111 +

+ +Jan 15, 2005 + +

New/Changed Features

+ + +

Bugs Fixed

+ + +
+

+ What's New for + D 0.110 +

+ +Dec 30, 2004 + +

New/Changed Features

+ + +

Bugs Fixed

+ + +
+

+ What's New for + D 0.109 +

+ +Dec 5, 2004 + +

New/Changed Features

+ + +

Bugs Fixed

+ + +
+

+ What's New for + D 0.108 +

+ +Nov 30, 2004 + +

Bugs Fixed

+ + +
+

+ What's New for + D 0.107 +

+ +Nov 29, 2004 + +

New/Changed Features

+ + +

Bugs Fixed

+ + +
+

+ What's New for + D 0.106 +

+ +Nov 9, 2004 + +

New/Changed Features

+ + +

Bugs Fixed

+ + +
+

+ What's New for + D 0.105 +

+ +Oct 28, 2004 + +

New/Changed Features

+ + +

Bugs Fixed

+ + +
+

+ What's New for + D 0.104 +

+ +Oct 21, 2004 + +

Bugs Fixed

+ + +
+

What's New for D 0.103

+ +Oct 20, 2004 + +

New/Changed Features

+ + +

Bugs Fixed

+ + +
+

What's New for D 0.102

+ +Sep 20, 2004 + +

New/Changed Features

+ + +

Bugs Fixed

+ + +
+

What's New for D 0.101

+ +Aug 30, 2004 + +

New/Changed Features

+ + +

Bugs Fixed

+ + +
+

What's New for D 0.100

+ +Aug 20, 2004 + +

Bugs Fixed

+ + +
+

What's New for D 0.99

+ +Aug 19, 2004 + +

New/Changed Features

+ + +

Bugs Fixed

+ + +
+

What's New for D 0.98

+ +Aug 5, 2004 + +

New/Changed Features

+ + +

Bugs Fixed

+ + +
+

What's New for D 0.97

+ +Jul 26, 2004 + +

New/Changed Features

+ + +

Bugs Fixed

+ + +
+

What's New for D 0.96

+ +Jul 21, 2004 + +

New/Changed Features

+ + +

Bugs Fixed

+ + +
+

What's New for D 0.95

+ +Jul 6, 2004 + +

New/Changed Features

+ + +

Bugs Fixed

+ + +
+

What's New for D 0.94

+ +Jun 27, 2004 + +

Bugs Fixed

+ + +
+

What's New for D 0.93

+ +Jun 22, 2004 + +

New/Changed Features

+ + +

Bugs Fixed

+ + +
+

What's New for D 0.92

+ +Jun 7, 2004 + +

New/Changed Features

+ + +

Bugs Fixed

+ + +
+

What's New for D 0.91

+ +May 27, 2004 + +

New/Changed Features

+ + +

Bugs Fixed

+ + +
+

What's New for D 0.90

+ +May 20, 2004 + +

Bugs Fixed

+ + +
+

What's New for D 0.89

+ +May 17, 2004 + +

New/Changed Features

+ + +

Bugs Fixed

+ + +
+

What's New for D 0.88

+ +May 5, 2004 + +

New/Changed Features

+ + +

Bugs Fixed

+ + +
+

What's New for D 0.86

+ +Apr 23, 2004 + +

New/Changed Features

+ + +

Bugs Fixed

+ + +
+

What's New for D 0.82

+ +Mar 28, 2004 + +

Bugs Fixed

+ + +
+

What's New for D 0.81

+ +Mar 7, 2004 + +

Bugs Fixed

+ + +
+

What's New for D 0.80

+ +Mar 5, 2004 + +

New/Changed Features

+ + +

Bugs Fixed

+ + +
+

What's New for D 0.79

+ +Feb 2, 2004 + +

New/Changed Features

+ + +

Bugs Fixed

+ + +
+

What's New for D 0.78

+ +Jan 14, 2004 + +

New/Changed Features

+ + +

Bugs Fixed

+ + +
+

What's New for D 0.77

+ +Jan 2, 2004 + +

New/Changed Features

+ + +

Bugs Fixed

+ + +
+

What's New for D 0.76

+ +Nov 21, 2003 + +

New/Changed Features

+ + +

Bugs Fixed

+ + +
+

What's New for D 0.75

+ +Nov 4, 2003 + +

New/Changed Features

+ + +
+

What's New for D 0.74

+ +Oct 15, 2003 + +

New/Changed Features

+ + +

Bugs Fixed

+ + +
+

What's New for D 0.73

+ +Sep 18, 2003 + +

New/Changed Features

+ + +

Bugs Fixed

+ + +
+

What's New for D 0.72

+ +Sep 14, 2003 + +

New/Changed Features

+ + +

Bugs Fixed

+ + +

Linux Bugs Fixed

+ + +
+

What's New for D 0.71

+ +Sep 3, 2003 + +

New/Changed Features

+ + +

Bugs Fixed

+ + +
+

What's New for D 0.70

+ +Aug 24, 2003 + +

New/Changed Features

+ + +

Bugs Fixed

+ + +
+

What's New for D 0.69

+ +Aug 11, 2003 + +

New/Changed Features

+ + +

Bugs Fixed

+ + +
+

What's New for D 0.68

+ +Jul 8, 2003 + + + +
+

What's New for D 0.67

+ +Jun 17, 2003 + + + +
+

What's New for D 0.66

+ +Jun 8, 2003 + + + +
+

What's New for D 0.65

+ +May 13, 2003 + +

linux version

+ + + +
+

What's New for D 0.64

+ +May 12, 2003 + +

linux version

+ + + +
+

What's New for D 0.63

+ +May 10, 2003 + + + +
+

What's New for D 0.61

+ +Mar 30, 2003 + + + +
+

What's New for D 0.59

+ +Mar 6, 2003 + + + +
+

What's New for D 0.58

+ +Mar 3, 2003 + + + +
+

What's New for D 0.57

+ +Feb 25, 2003 + + + +Many thanks to Burton Radons for his help with this. + +
+

What's New for D 0.56

+ +Feb 20, 2003 + + + +
+

What's New for D 0.55

+ +Feb 17, 2003 + + + +
+

What's New for D 0.54

+ +Feb 14, 2003 + + + + These changes have been needed for a while, and it's time to + put them in before D gets too constrained by legacy code. + Fortunately, using grep and global/search/replace can easily + take care of the type renames. + The array declaration issue can be fixed + by grepping for "][", and then manually fixing each. + + +
+

What's New for D 0.53

+ +Feb 8, 2003 + + + + +
+

What's New for D 0.52

+ +Feb 5, 2003 + + + + +
+

What's New for D 0.51

+ +Jan 27, 2003 + + + + +
+

What's New for D 0.50

+ +Nov 20, 2002 + + + + +
+

What's New for D 0.49

+ +Nov 18, 2002 + + + + +
+

What's New for D 0.48

+ +Oct 25, 2002 + + + + +
+

What's New for D 0.46

+ +Oct 22, 2002 + + + + +
+

What's New for D 0.45

+ +Oct 8, 2002 + + + + +
+

What's New for D 0.44

+ +Oct 1, 2002 + + + + +
+

What's New for D 0.43

+ +Sep 28, 2002 + + + +

Feedback and Comments

+ + Add feedback and comments regarding this + page. + +
+Copyright © 1999-2005 by Digital Mars, All Rights Reserved

+ + + + + + + + + + diff -uNr dmd-0.125/dmd/html/d/class.html dmd-0.126/dmd/html/d/class.html --- dmd-0.125/dmd/html/d/class.html 2005-05-19 11:44:48.000000000 +0200 +++ dmd-0.126/dmd/html/d/class.html 2005-06-07 01:31:22.000000000 +0200 @@ -28,7 +28,7 @@ D Programming Language - Classes - + www.digitalmars.com @@ -37,7 +37,7 @@ | D
-Last update Thu May 19 2005 +Last update Tue Jun 07 2005


@@ -61,15 +61,35 @@ A class declaration is defined: -
+	

+
+

 	ClassDeclaration:
-		class Identifier [SuperClass {, InterfaceClass }] ClassBody
+		class Identifier BaseClassListopt ClassBody
+
+	BaseClassList:
+		: SuperClass
+		: SuperClass InterfaceClasses
+		: InterfaceClass
+		: InterfaceClass InterfaceClasses
 
 	SuperClass:
-		: Identifier
+		Identifier
+		Protection Identifier
+
+	InterfaceClasses:
+		InterfaceClass
+		InterfaceClass InterfaceClasses
 
 	InterfaceClass:
 		Identifier
+		Protection Identifier
+
+	Protection:
+		private
+		package
+		public
+		export
 
 	ClassBody:
 		{ }
@@ -89,7 +109,7 @@
 		UnitTest
 		ClassAllocator
 		ClassDeallocator
-	
+

Classes consist of: @@ -116,28 +136,35 @@ -A class is defined: + 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: +

-

+	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: + Instead: -

+	

+
+

 	class Foo { }
 	Foo var;
-
+

Fields

@@ -166,7 +193,10 @@ .offsetof can only be applied to fields qualified with the type of the class, not expressions which produce the type of the field itself: -
+
+	

+
+

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

Super Class

@@ -189,10 +219,12 @@

Constructors

-
+	

+
+

 	Constructor:
-		this() BlockStatement
-	
+ this( ParameterList ) BlockStatement +

Members are always initialized to the default initializer for their type, which is usually 0 for integer types and @@ -204,14 +236,16 @@ 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. @@ -220,7 +254,9 @@ Constructors are defined with a function name of this and having no return value: -

+	

+
+

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

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

+	

+
+

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

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

+	

+
+

 	class C
 	{
 	    int j;
@@ -267,7 +307,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 @@ -277,9 +317,11 @@ 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.

@@ -288,14 +330,21 @@ apply:

  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
    @@ -307,7 +356,8 @@
     		super();	// illegal, inside loop
     	    }
     	}
    -	
    +

    +

  3. It is illegal to refer to this implicitly or explicitly prior to making a constructor call.
  4. Constructor calls cannot appear after labels (in order to make @@ -316,9 +366,11 @@ Instances of class objects are created with NewExpressions: -
    +	

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

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

    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, @@ -406,14 +462,17 @@

    Static Constructors

    -
    +	

    +
    +
    
     	StaticConstructor:
     		static this() BlockStatement
    -	
    +

    A static constructor is defined as a function that performs initializations before the - main() function gets control. Static constructors are used to initialize + main() function gets control. Static constructors are used to + initialize static class members with values that cannot be computed at compile time.

    @@ -424,13 +483,15 @@ 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 @@ -450,7 +511,9 @@ initialization is performed by a static constructor, defined with a special syntax static this(). -

    +	

    +
    +
    
     	class Foo
     	{
     	    static int a;		// default initialized to 0
    @@ -463,7 +526,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 @@ -483,7 +546,9 @@ 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
    @@ -494,25 +559,31 @@
     	    }
     	    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 @@ -525,7 +596,9 @@ 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
    @@ -536,14 +609,17 @@
     	    }
     	    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 @@ -552,19 +628,22 @@ -

    -    class Date
    -    {
    -	int day;
    -	int hour;
    -
    -	invariant
    +	

    +
    +
    
    +	class Date
     	{
    -	    assert(1 <= day && day <= 31);
    -	    assert(0 <= hour && hour < 24);
    +	    int day;
    +	    int hour;
    +
    +	    invariant
    +	    {
    +		assert(1 <= day && day <= 31);
    +		assert(0 <= hour && hour < 24);
    +	    }
     	}
    -    }
    -
    +

    + The class invariant is a contract saying that the asserts must hold true. The invariant is checked when a class constructor completes, @@ -578,43 +657,53 @@ 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() { }
    -	private void g() { }
    -
    -	invariant
    +	

    +
    +
    
    +	class Foo
     	{
    -	    f();  // error, cannot call public member function from invariant
    -	    g();  // ok, g() is not public
    +	    public void f() { }
    +	    private void g() { }
    +
    +	    invariant
    +	    {
    +		f();  // error, cannot call public member function from invariant
    +		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, any class invariant is implicitly anded with the invariants of its base classes. -

    +

    + There can be only one ClassInvariant per class. -

    +

    + When compiling for release, the invariant code is not generated, and the compiled program runs at maximum speed.

    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 @@ -624,51 +713,61 @@ code.

    - D classes can have a special member function called: + Classes can have a special member function called: -

    +	

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

    - The test() functions for all the classes in the program get called - after static initialization is done and before the main function - is called. A compiler or linker switch will remove the test code - from the final build. + A compiler switch, such as -unittest for dmd, will + cause the unittest test code to be compiled and incorporated into + the resulting executable. The unittest code gets run after + static initialization is run and before the main() + function is called.

    For example, given a class Sum that is used to add two values: -

    +	

    +
    +
    
     	class Sum
     	{
     	    int add(int x, int y) { return x + y; }
     
     	    unittest
     	    {
    -		assert(add(3,4) == 7);
    -		assert(add(-2,0) == -2);
    +		Sum sum = new Sum;
    +		assert(sum.add(3,4) == 7);
    +		assert(sum.add(-2,0) == -2);
     	    }
     	}
    -	
    +

    Class Allocators

    -
    +	

    +
    +
    
     	ClassAllocator:
    -		new ParameterList BlockStatement
    -	
    + 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 @@ -677,9 +776,11 @@ 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 @@ -693,7 +794,9 @@ additional arguments are specified within parentheses after the new in the NewExpression: -

    +	

    +
    +
    
     	class Foo
     	{
     	    this(char[] a) { ... }
    @@ -707,7 +810,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. @@ -717,28 +820,34 @@

    Class Deallocators

    -
    +	

    +
    +
    
     	ClassDeallocator:
    -		delete ParameterList BlockStatement
    -	
    + 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 @@ -757,9 +866,11 @@ 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. @@ -768,7 +879,9 @@ An auto class reference can only appear as a function local variable. It must be declared as being auto: -

    +	

    +
    +
    
     	auto class Foo { ... }
     
     	void func()
    @@ -776,186 +889,213 @@
     	    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 the scope was exited via a thrown exception. -


    -

    Interfaces

    - -
    -	InterfaceDeclaration:
    -		interface Identifier InterfaceBody
    -		interface Identifier : SuperInterfaces InterfaceBody
    -
    -	SuperInterfaces
    -		Identifier
    -		Identifier , SuperInterfaces
    -
    -	InterfaceBody:
    -		{ DeclDefs }
    -	
    +

    Nested Classes

    - Interfaces describe a list of functions that a class that inherits - from the interface must implement. - A class that implements an interface can be converted to a reference - to that interface. Interfaces correspond to the interface exposed - by operating system objects, like COM/OLE/ActiveX for Win32. -

    + A nested class is a class that is declared inside the scope + of a function or another class. + A nested class has access to the variables and other symbols + of the classes and functions it is nested inside: - Interfaces cannot derive from classes; only from other interfaces. - Classes cannot derive from an interface multiple times. - -

    -	interface D
    +	

    +
    +
    
    +	class Outer
     	{
    -	    void foo();
    -	}
    +	    int m;
     
    -	class A : D, D	// error, duplicate interface
    -	{
    +	    class Inner
    +	    {
    +		int foo()
    +		{
    +		    return m;	// Ok to access member of Outer
    +		}
    +	    }
     	}
    -	
    - - An instance of an interface cannot be created. + void func() + { int m; -
    -	interface D
    -	{
    -	    void foo();
    +	    class Inner
    +	    {
    +		int foo()
    +		{
    +		    return m;	// Ok to access local variable m of func()
    +		}
    +	    }
     	}
    +	

    - ... - - D d = new D(); // error, cannot create instance of interface -

    - - Interface member functions do not have implementations. + 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: -
    -	interface D
    +	

    +
    +
    
    +	class Outer
     	{
    -	    void bar() { }	// error, implementation not allowed
    +	    int m;
    +	    static int n;
    +
    +	    static class Inner
    +	    {
    +		int foo()
    +		{
    +		    return m;	// Error, Inner is static and m needs a this
    +		    return n;	// Ok, n is static
    +		}
    +	    }
     	}
    -	
    - All interface functions must be defined in a class that inherits - from that interface: + void func() + { int m; + static int n; -
    -	interface D
    -	{
    -	    void foo();
    +	    class Inner
    +	    {
    +		int foo()
    +		{
    +		    return m;	// Error, Inner is static and m is local to the stack
    +		    return n;	// Ok, n is static
    +		}
    +	    }
     	}
    +	

    - class A : D + Non-static nested classes work by containing an extra hidden member + (called the context pointer) + that is the frame pointer of the enclosing function if it is nested + inside a function, or the this of the enclosing class's instance + if it is nested inside a class. +

    + + When a non-static nested class is instantiated, the context pointer + is assigned before the class's constructor is called, therefore + the constructor has full access to the enclosing variables. + A non-static nested class can only be instantiated when the necessary + context pointer information is available: + +

    +
    +
    
    +	class Outer
     	{
    -	    void foo() { }	// ok, provides implementation
    +	    class Inner { }
    +
    +	    static class SInner { }
     	}
     
    -	class B : D
    +	void func()
     	{
    -	    int foo() { }	// error, no void foo() implementation
    -	}
    -	
    + class Nested { } - Interfaces can be inherited and functions overridden: + Outer o = new Outer; // Ok + Outer.Inner oi = new Outer.Inner; // Error, no 'this' for Outer + Outer.SInner os = new Outer.SInner; // Ok -
    -	interface D
    -	{
    -	    int foo();
    +	    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 A : D +

    +
    +
    
    +	class Base
     	{
     	    int foo() { return 1; }
     	}
     
    -	class B : A
    -	{
    -	    int foo() { return 2; }
    -	}
    +	Base func()
    +	{   int m = 3;
     
    -	...
    +	    class Nested : Base
    +	    {
    +		int foo() { return m; }
    +	    }
     
    -	B b = new B();
    -	b.foo();		// returns 2
    -	D d = (D) b;		// ok since B inherits A's D implementation
    -	d.foo();		// returns 2;
    -	
    + Base b = new Nested; - Interfaces can be reimplemented in derived classes: + assert(b.foo() == 3); // Ok, func() is still active + return b; + } -
    -	interface D
    +	int test()
     	{
    -	    int foo();
    +	    Base b = func();
    +	    return b.foo();		// Error, func().m is undefined
     	}
    +	

    - class A : D + 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; }
     	}
     
    -	class B : A, D
    -	{
    -	    int foo() { return 2; }
    -	}
    +	Base func()
    +	{   int m = 3;
     
    -	...
    +	    class Nested : Base
    +	    {	int m_;
     
    -	B b = new B();
    -	b.foo();		// returns 2
    -	D d = (D) b;
    -	d.foo();		// returns 2
    -	A a = (A) b;
    -	D d2 = (D) a;
    -	d2.foo();		// returns 2, even though it is A's D, not B's D
    -	
    + this() { m_ = m; + int foo() { return m_; } + } - A reimplemented interface must implement all the interface - functions, it does not inherit them from a super class: + Base b = new Nested; -
    -	interface D
    -	{
    -	    int foo();
    +	    assert(b.foo() == 3);	// Ok, func() is still active
    +	    return b;
     	}
     
    -	class A : D
    +	int test()
     	{
    -	    int foo() { return 1; }
    +	    Base b = func();
    +	    return b.foo();		// Ok, using cached copy of func().m
     	}
    +	

    - class B : A, D - { - } // error, no foo() for interface D -

    +

    Anonymous Nested Classes

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

    COM Interfaces

    +

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

    - A variant on interfaces is the COM interface. A COM interface is - designed to map directly onto a Windows COM object. Any COM object - can be represented by a COM interface, and any D object with - a COM interface can be used by external COM clients. -

    - - A COM interface is defined as one that derives from the interface - std.c.windows.com.IUnknown. A COM interface differs from - a regular D interface in that: - -

      -
    • It derives from the interface std.c.windows.com.IUnknown. -
    • It cannot be the argument of a DeleteExpression. -
    • References cannot be upcast to the enclosing class object, nor - can they be downcast to a derived interface. To accomplish this, - an appropriate QueryInterface() would have to be implemented - for that interface in standard COM fashion. -
    + 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

    @@ -966,6 +1106,20 @@
    Copyright © 1999-2005 by Digital Mars, All Rights Reserved

    + + + + + diff -uNr dmd-0.125/dmd/html/d/comparison.html dmd-0.126/dmd/html/d/comparison.html --- dmd-0.125/dmd/html/d/comparison.html 2005-05-01 00:46:22.000000000 +0200 +++ dmd-0.126/dmd/html/d/comparison.html 2005-06-06 18:21:14.000000000 +0200 @@ -228,7 +228,7 @@ Interfaces - Yes + Yes No Yes Yes diff -uNr dmd-0.125/dmd/html/d/cppcomplex.html dmd-0.126/dmd/html/d/cppcomplex.html --- dmd-0.125/dmd/html/d/cppcomplex.html 2005-05-19 11:44:48.000000000 +0200 +++ dmd-0.126/dmd/html/d/cppcomplex.html 2005-05-19 15:08:48.000000000 +0200 @@ -28,7 +28,7 @@ D Programming Language - D Complex Types vs C++ std::complex - + www.digitalmars.com @@ -265,6 +265,20 @@


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

    + + + + + diff -uNr dmd-0.125/dmd/html/d/cppdbc.html dmd-0.126/dmd/html/d/cppdbc.html --- dmd-0.125/dmd/html/d/cppdbc.html 2005-05-19 11:44:48.000000000 +0200 +++ dmd-0.126/dmd/html/d/cppdbc.html 2005-05-19 15:08:48.000000000 +0200 @@ -28,7 +28,7 @@ D Programming Language - D's Contract Programming vs C++'s - + www.digitalmars.com @@ -561,6 +561,20 @@


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

    + + + + + diff -uNr dmd-0.125/dmd/html/d/cppstrings.html dmd-0.126/dmd/html/d/cppstrings.html --- dmd-0.125/dmd/html/d/cppstrings.html 2005-05-19 11:44:48.000000000 +0200 +++ dmd-0.126/dmd/html/d/cppstrings.html 2005-05-19 15:08:48.000000000 +0200 @@ -28,7 +28,7 @@ D Programming Language - D Strings vs C++ Strings - + www.digitalmars.com @@ -591,6 +591,20 @@


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

    + + + + + diff -uNr dmd-0.125/dmd/html/d/cpptod.html dmd-0.126/dmd/html/d/cpptod.html --- dmd-0.125/dmd/html/d/cpptod.html 2005-05-19 11:44:48.000000000 +0200 +++ dmd-0.126/dmd/html/d/cpptod.html 2005-06-06 17:53:30.000000000 +0200 @@ -29,7 +29,7 @@ Digital Mars - Programming in D for C++ Programmers - + www.digitalmars.com @@ -38,7 +38,7 @@ | D
    -Last update Thu May 19 2005 +Last update Mon Jun 06 2005


    Programming in D for C++ Programmers

    @@ -65,9 +65,8 @@
  5. RAII (Resource Acquisition Is Initialization)
  6. Properties
  7. Recursive Templates - +
  8. Type Traits @@ -667,7 +666,7 @@ }

  9. - + +
    + +

    Type Traits

    + + Type traits are another term for being able to find out + properties of a type at compile time. + +

    The C++ Way

    + + The following template comes from + + C++ Templates: The Complete Guide, David Vandevoorde, Nicolai M. Josuttis + pg. 353 which determines if the template's argument type + is a function: + +

    +
    +
    
    +	template<typename T> class IsFunctionT
    +	{
    +	    private:
    +		typedef char One;
    +		typedef struct { char a[2]; } Two;
    +		template<typename U> static One test(...);
    +		template<typename U> static Two test(U (*)[1]);
    +	    public:
    +		enum { Yes = sizeof(IsFunctionT<T>::test<T>(0)) == 1 };
    +	};
    +
    +	void test()
    +	{
    +	    typedef int (fp)(int);
    +
    +	    assert(IsFunctionT<fp>::Yes == 1);
    +	}
    +	

    + + This template relies on the + SFINAE + (Substitution Failure Is Not An Error) principle. + Why it works is a fairly advanced template topic. + +

    The D Way

    + + SFINAE can be done in D without resorting to template partial + specializations: + +

    +
    +
    
    +	template IsFunctionT(T)
    +	{
    +	    static if ( is(T[]) )
    +		const int IsFunctionT = 1;
    +	    else
    +		const int IsFunctionT = 0;
    +	}
    +
    +	void test()
    +	{
    +	    typedef int fp(int);
    +
    +	    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 + create the invalid array of functions type. + The is + expression can test it directly: + +

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

    +

    Feedback and Comments

    @@ -802,6 +884,20 @@
    Copyright © 1999-2005 by Digital Mars, All Rights Reserved

    + + + + + diff -uNr dmd-0.125/dmd/html/d/ctod.html dmd-0.126/dmd/html/d/ctod.html --- dmd-0.125/dmd/html/d/ctod.html 2005-05-19 11:44:48.000000000 +0200 +++ dmd-0.126/dmd/html/d/ctod.html 2005-05-22 02:32:44.000000000 +0200 @@ -28,7 +28,7 @@ Digital Mars - Programming in D for C Programmers - + www.digitalmars.com @@ -37,7 +37,7 @@ | D
    -Last update Thu May 19 2005 +Last update Sun May 22 2005


    Programming in D for C Programmers

    @@ -97,6 +97,7 @@
  10. Data Structure Traversal
  11. Unsigned Right Shift
  12. Dynamic Closures +
  13. Variadic Function Parameters -

    Dynamic Closures

    +

    Dynamic Closures

    The C Way

    @@ -1731,6 +1732,85 @@ eliminating the need to create irrelevant function names. +
    +

    Variadic Function Parameters

    + + The task is to write a function that takes a varying + number of arguments, such as a function that sums + its arguments. + +

    The C Way

    + +

    +
    +
    
    +	#include <stdio.h>
    +	#include <stdarg.h>
    +
    +	int sum(int dim, ...)
    +	{   int i;
    +	    int s = 0;
    +	    va_list ap;
    +
    +	    va_start(ap, dim);
    +	    for (i = 0; i < dim; i++)
    +		s += va_arg(ap, int);
    +	    va_end(ap);
    +	    return s;
    +	}
    +
    +	int main()
    +	{
    +	    int i;
    +
    +	    i = sum(3, 8,7,6);
    +	    printf("sum = %d\n", i);
    +
    +	    return 0;
    +	} 
    +	

    + + There are two problems with this. The first is that the + sum function needs to know how many arguments were + supplied. It has to be explicitly written, and it can get + out of sync with respect to the actual number of arguments + written. + The second is that there's no way to check that the + types of the arguments provided really were ints, and not + doubles, strings, structs, etc. + +

    The D Way

    + + The ... following an array parameter declaration means that + the trailing arguments are collected together to form + an array. The arguments are type checked against the array + type, and the number of arguments becomes a property + of the array: + +

    +
    +
    
    +	int sum(int[] values ...)
    +	{
    +	    int s = 0;
    +
    +	    foreach (int x; values)
    +		s += x;
    +	    return s;
    +	}
    +
    +	int main()
    +	{
    +	    int i;
    +
    +	    i = sum(8,7,6);
    +	    printf("sum = %d\n", i);
    +
    +	    return 0;
    +	}
    +	

    + +

    Feedback and Comments

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

    + + + + + diff -uNr dmd-0.125/dmd/html/d/dbc.html dmd-0.126/dmd/html/d/dbc.html --- dmd-0.125/dmd/html/d/dbc.html 2005-05-19 11:44:48.000000000 +0200 +++ dmd-0.126/dmd/html/d/dbc.html 2005-05-19 15:08:50.000000000 +0200 @@ -28,7 +28,7 @@ D Programming Language - Contract Programming - + www.digitalmars.com @@ -262,6 +262,20 @@


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

    + + + + + diff -uNr dmd-0.125/dmd/html/d/dcompiler.html dmd-0.126/dmd/html/d/dcompiler.html --- dmd-0.125/dmd/html/d/dcompiler.html 2005-05-19 11:44:48.000000000 +0200 +++ dmd-0.126/dmd/html/d/dcompiler.html 2005-05-19 15:08:50.000000000 +0200 @@ -28,7 +28,7 @@ D Programming Language - DMD Compiler - + www.digitalmars.com @@ -562,6 +562,20 @@


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

    + + + + + diff -uNr dmd-0.125/dmd/html/d/declaration.html dmd-0.126/dmd/html/d/declaration.html --- dmd-0.125/dmd/html/d/declaration.html 2005-05-19 11:44:48.000000000 +0200 +++ dmd-0.126/dmd/html/d/declaration.html 2005-06-01 14:50:06.000000000 +0200 @@ -28,7 +28,7 @@ D Programming Language - Declarations - + www.digitalmars.com @@ -37,7 +37,7 @@ | D
    -Last update Thu May 19 2005 +Last update Wed Jun 01 2005


    Declarations

    @@ -168,6 +168,12 @@ out inout + Initializer: + void + AssignExpression + ArrayInitializer + StructInitializer +
  14. Declaration Syntax

    @@ -460,6 +466,20 @@
    Copyright © 1999-2005 by Digital Mars, All Rights Reserved

    + + + + + diff -uNr dmd-0.125/dmd/html/d/dlinks.html dmd-0.126/dmd/html/d/dlinks.html --- dmd-0.125/dmd/html/d/dlinks.html 2005-05-19 11:44:48.000000000 +0200 +++ dmd-0.126/dmd/html/d/dlinks.html 2005-06-07 02:52:40.000000000 +0200 @@ -30,7 +30,7 @@ Digital Mars - The D Programming Language - + www.digitalmars.com @@ -39,7 +39,7 @@ | D
    -Last update Thu May 19 2005 +Last update Tue Jun 07 2005


    D Links

    @@ -50,21 +50,35 @@

    Tools

    @@ -422,6 +436,20 @@
    Copyright © 1999-2005 by Digital Mars, All Rights Reserved

    + + + + + diff -uNr dmd-0.125/dmd/html/d/dll.html dmd-0.126/dmd/html/d/dll.html --- dmd-0.125/dmd/html/d/dll.html 2005-05-19 11:44:48.000000000 +0200 +++ dmd-0.126/dmd/html/d/dll.html 2005-05-19 15:08:50.000000000 +0200 @@ -28,7 +28,7 @@ D Programming Language - Writing Win32 DLLs - + www.digitalmars.com @@ -684,6 +684,20 @@


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

    + + + + + diff -uNr dmd-0.125/dmd/html/d/dstyle.html dmd-0.126/dmd/html/d/dstyle.html --- dmd-0.125/dmd/html/d/dstyle.html 2005-05-19 11:44:48.000000000 +0200 +++ dmd-0.126/dmd/html/d/dstyle.html 2005-05-19 15:08:50.000000000 +0200 @@ -28,7 +28,7 @@ D Programming Language - The D Style - + www.digitalmars.com @@ -220,6 +220,20 @@


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

    + + + + + diff -uNr dmd-0.125/dmd/html/d/entity.html dmd-0.126/dmd/html/d/entity.html --- dmd-0.125/dmd/html/d/entity.html 2005-05-19 11:44:48.000000000 +0200 +++ dmd-0.126/dmd/html/d/entity.html 2005-05-19 15:08:50.000000000 +0200 @@ -28,7 +28,7 @@ D Programming Language - Named Character Entities - + www.digitalmars.com @@ -328,6 +328,20 @@


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

    + + + + + diff -uNr dmd-0.125/dmd/html/d/enum.html dmd-0.126/dmd/html/d/enum.html --- dmd-0.125/dmd/html/d/enum.html 2005-05-19 11:44:48.000000000 +0200 +++ dmd-0.126/dmd/html/d/enum.html 2005-05-19 15:08:50.000000000 +0200 @@ -28,7 +28,7 @@ D Programming Language - Enums - + www.digitalmars.com @@ -159,6 +159,20 @@


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

    + + + + + diff -uNr dmd-0.125/dmd/html/d/errors.html dmd-0.126/dmd/html/d/errors.html --- dmd-0.125/dmd/html/d/errors.html 2005-05-19 11:44:48.000000000 +0200 +++ dmd-0.126/dmd/html/d/errors.html 2005-05-19 15:08:50.000000000 +0200 @@ -28,7 +28,7 @@ D Programming Language - Errors - + www.digitalmars.com @@ -251,6 +251,20 @@


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

    + + + + + diff -uNr dmd-0.125/dmd/html/d/expression.html dmd-0.126/dmd/html/d/expression.html --- dmd-0.125/dmd/html/d/expression.html 2005-05-19 11:44:48.000000000 +0200 +++ dmd-0.126/dmd/html/d/expression.html 2005-06-07 01:31:22.000000000 +0200 @@ -28,7 +28,7 @@ D Programming Language - Expressions - + www.digitalmars.com @@ -37,7 +37,7 @@ | D
    -Last update Thu May 19 2005 +Last update Tue Jun 07 2005


    Expressions

    @@ -102,6 +102,7 @@ EqualExpression == RelExpression EqualExpression != RelExpression EqualExpression is RelExpression + EqualExpression !is RelExpression RelExpression: ShiftExpression @@ -152,6 +153,7 @@ ~ UnaryExpression delete UnaryExpression NewExpression + NewAnonClassExpression cast ( Type ) UnaryExpression ( Type ) . Identifier ( Expression ) @@ -186,6 +188,7 @@ AssertExpression BasicType . Identifier typeid ( Type ) + IsExpression AssertExpression: assert ( Expression ) @@ -402,7 +405,6 @@
    
     	EqualExpression == RelExpression
     	EqualExpression != RelExpression
    -	EqualExpression is RelExpression
     	

    Equality expressions compare the two operands for equality (==) @@ -453,10 +455,11 @@

    
     	EqualExpression is RelExpression
    +	EqualExpression !is RelExpression
     	

    The is compares for identity. - To compare for not identity, use !(e1 is e2). + To compare for not identity, use e1 !is e2. The type of the result is bool. The operands go through the usual conversions to bring them to a common type before comparison. @@ -1038,6 +1041,7 @@ Otherwise, it resolves to the type with the smallest size it will fit into. +

    Function Literals

    @@ -1193,6 +1197,263 @@ Returns an instance of class TypeInfo corresponding to Type. +

    IsExpression

    + +

    +
    +
    
    +	IsExpression:
    +		is ( Type )
    +		is ( Type : TypeSpecialization )
    +		is ( Type == TypeSpecialization )
    +		is ( Type Identifier )
    +		is ( Type Identifier : TypeSpecialization )
    +		is ( Type Identifier == TypeSpecialization )
    +
    +	TypeSpecialization:
    +		Type
    +		typedef
    +		struct
    +		union
    +		class
    +		interface
    +		enum
    +		function
    +		delegate
    +	

    + + IsExpressions are evaluated at compile time and are + used for checking for valid types, comparing types for equivalence, + determining if one type can be implicitly converted to another, + and deducing the subtypes of a type. + The result of an IsExpression is an int of type 0 + if the condition is not satisified, 1 if it is. +

    + + Type is the type being tested. It must be syntactically + correct, but it need not be semantically correct. + If it is not semantically correct, the condition is not satisfied. +

    + + Identifier is declared to be an alias of the resulting + type if the condition is satisfied. The Identifier forms + can only be used if the IsExpression appears in a + StaticIfCondition. +

    + + TypeSpecialization is the type that Type is being + compared against. +

    + + The forms of the IsExpression are: + +

      + +
    1. is ( Type )
      + 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()
      +	{
      +	    if ( is(func[]) )	// not satisfied because arrays of
      +				// functions are not allowed
      +		printf("satisfied\n");
      +	    else
      +		printf("not satisfied\n");
      +
      +	    if (is([][]))	// error, [][] is not a syntactically valid type
      +		...
      +	}
      +	

      + +

    2. is ( Type : TypeSpecialization )
      + The condition is satisfied if Type is semantically + correct and it is the same as + or can be implicitly converted to TypeSpecialization. + TypeSpecialization is only allowed to be a Type. + +

      +
      +
      
      +	alias short bar;
      +	void foo(bar x)
      +	{
      +	    if ( is(bar : int) )	// satisfied because short can be
      +					// implicitly converted to int
      +		printf("satisfied\n");
      +	    else
      +		printf("not satisfied\n");
      +	}
      +	

      + +

    3. is ( Type == TypeSpecialization )
      + The condition is satisfied if Type is semantically + correct and is the same type as TypeSpecialization. +

      + + If TypeSpecialization is one of + typedef + struct + union + class + interface + enum + function + delegate + then the condition is satisifed if Type is one of those. + +

      +
      +
      
      +	alias short bar;
      +	typedef char foo;
      +	void foo(bar x)
      +	{
      +	    if ( is(bar == int) )	// not satisfied because short is not
      +					// the same type as int
      +		printf("satisfied\n");
      +	    else
      +		printf("not satisfied\n");
      +
      +	    if ( is(foo == typedef) )	// satisfied because foo is a typedef
      +		printf("satisfied\n");
      +	    else
      +		printf("not satisfied\n");
      +	}
      +	

      + +

    4. 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)
      +	{
      +	    static if ( is(bar T) )
      +		alias T S;
      +	    else
      +		alias long S;
      +	    writefln(typeid(S));	// prints "short"
      +
      +	    if ( is(bar T) )	// error, Identifier T form can
      +					// only be in StaticIfConditions
      +		...
      +	}
      +	

      + +

    5. is ( Type Identifier : TypeSpecialization )
      + The condition is satisfied if Type is the same as + or can be implicitly converted to TypeSpecialization. + The Identifier is declared to be either an alias of the + TypeSpecialization or, if TypeSpecialization is + 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)
      +	{
      +	    static if ( is(bar T : int) )
      +		alias T S;
      +	    else
      +		alias long S;
      +
      +	    writefln(typeid(S));	// prints "int"
      +
      +	    static if ( is(abc U : U*) )
      +		U u;
      +
      +	    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 + TemplateTypeParameterSpecialization. +

      + +

    6. is ( Type Identifier == TypeSpecialization )
      + The condition is satisfied if Type is semantically + correct and is the same as TypeSpecialization. + The Identifier is declared to be either an alias of the + TypeSpecialization or, if TypeSpecialization is + dependent on Identifier, the deduced type. +

      + + If TypeSpecialization is one of + typedef + struct + union + class + interface + enum + function + delegate + then the condition is satisifed if Type is one of those. + Furthermore, Identifier is set to be an alias of the type: +

      + + + + + + + + + + + +
      keyword + alias type for Identifier +
      typedef + the type that Type is a typedef of +
      struct + Type +
      union + Type +
      class + Type +
      interface + Type +
      enum + the base type of the enum +
      function + the return type of the function +
      delegate + the function type of the delegate +
      + +

      +
      +
      
      +alias short bar;
      +enum E : byte { Emember }
      +void foo(bar x, abc a)
      +{
      +    static if ( is(bar T == int) )	// not satisfied, short is not int
      +	alias T S;
      +    alias T U;				// error, T is not defined
      +
      +    static if ( is(E V == enum) )	// satisified, E is an enum
      +	V x;				// x is declared to be a byte
      +}
      +	

      + +

    + + +

    Feedback and Comments

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

    + + + + + diff -uNr dmd-0.125/dmd/html/d/faq.html dmd-0.126/dmd/html/d/faq.html --- dmd-0.125/dmd/html/d/faq.html 2005-05-19 11:44:48.000000000 +0200 +++ dmd-0.126/dmd/html/d/faq.html 2005-05-19 15:08:50.000000000 +0200 @@ -28,7 +28,7 @@ D Programming Language - FAQ - + www.digitalmars.com @@ -524,6 +524,20 @@


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

    + + + + + diff -uNr dmd-0.125/dmd/html/d/float.html dmd-0.126/dmd/html/d/float.html --- dmd-0.125/dmd/html/d/float.html 2005-05-19 11:44:48.000000000 +0200 +++ dmd-0.126/dmd/html/d/float.html 2005-05-19 15:08:50.000000000 +0200 @@ -28,7 +28,7 @@ D Programming Language - Floating Point - + www.digitalmars.com @@ -191,6 +191,20 @@


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

    + + + + + diff -uNr dmd-0.125/dmd/html/d/function.html dmd-0.126/dmd/html/d/function.html --- dmd-0.125/dmd/html/d/function.html 2005-05-19 11:44:48.000000000 +0200 +++ dmd-0.126/dmd/html/d/function.html 2005-05-22 19:28:06.000000000 +0200 @@ -28,7 +28,7 @@ D Programming Language - Functions - + www.digitalmars.com @@ -37,7 +37,7 @@ | D
    -Last update Thu May 19 2005 +Last update Sun May 22 2005


    Functions

    @@ -324,33 +324,49 @@

    -

    Variadic Function Parameters

    +

    Variadic Functions

    - Functions can be variadic, meaning they can take an arbitrary - number of parameters. A variadic function is declared as taking - a parameter of ... after the required function parameters: + Functions taking a variable number of arguments are called + variadic functions. A variadic function can take one of + three forms: + +
      +
    1. C-style variadic functions +
    2. Variadic functions with type info +
    3. Typesafe variadic functions +
    + + +

    C-style Variadic Functions

    + + A C-style variadic function is declared as taking + a parameter of ... after the required function parameters. + It has non-D linkage, such as extern (C):

    
    -	int foo(int x, int y, ...);
    +	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
     	

    - Variadic functions with non-D linkage must have at least one - non-variadic parameter declared. + There must have at least one non-variadic parameter declared.

    
    -	int abc(...);		// ok, D linkage
    -	extern (C) def(...);	// error, must have at least one parameter
    +	extern (C) int def(...); // error, must have at least one parameter
     	

    - Variadic functions have a special local variable declared for them, + This kind of function matches the C calling convention for + variadic functions, and is most useful for calling C library + functions like printf. + + The implementiations of these variadic functions have a special + local variable declared for them, _argptr, which is a void* pointer to the first of the variadic arguments. To access the arguments, _argptr must be cast @@ -368,7 +384,50 @@ }

    - For variadic functions with D linkage, an additional hidden argument + 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

    + + Variadic functions with argument and type info are declared as taking + a parameter of ... after the required function parameters. + 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, + _argptr, which is a void* pointer to the first of the + variadic + 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, ...)
    +	{   int z;
    +
    +	    z = *cast(int*)_argptr;	// z is set to 5
    +	}
    +	

    + + An additional hidden argument with the name _arguments and type TypeInfo[] is passed to the function. _arguments gives the number of arguments and the type @@ -481,7 +540,121 @@ }

    -

    Local Variables

    +

    Typesafe Variadic Functions

    + + Typesafe variadic functions are used when the variable argument + portion of the arguments are used to construct an array or + class object. +

    + + For arrays: + +

    +
    +
    
    +	int test()
    +	{
    +	    return sum(1, 2, 3) + sum(); // returns 6+0
    +	}
    +
    +	int func()
    +	{
    +	    static int[3] ii = [4, 5, 6];
    +	    return sum(ii);		// returns 15
    +	}
    +	
    +	void sum(int[] ar ...)
    +	{
    +	    int s;
    +	    foreach (int x; ar)
    +		s += x;
    +	    return s;
    +	}
    +	

    + + For static arrays: + +

    +
    +
    
    +	int test()
    +	{
    +	    return sum(2, 3);	// error, need 3 values for array
    +	    return sum(1, 2, 3); // returns 6
    +	}
    +
    +	int func()
    +	{
    +	    static int[3] ii = [4, 5, 6];
    +	    int[] jj = ii;
    +	    return sum(ii);		// returns 15
    +	    return sum(jj);		// error, type mismatch
    +	}
    +	
    +	void sum(int[3] ar ...)
    +	{
    +	    int s;
    +	    foreach (int x; ar)
    +		s += x;
    +	    return s;
    +	}
    +	

    + + For class objects: + +

    +
    +
    
    +	class Foo { int x; char[] s; }
    +
    +	void test(int x, Foo f ...);
    +
    +	...
    +
    +	Foo g = new Foo(3, "abc");
    +	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
    +	}
    +
    +	int[] test(int[] a ...)
    +	{
    +	    return a;		// error, array contents invalid after return
    +	    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;
    +	}
    +
    +	...
    +	test(3);	// returns 3
    +	test(3, 4);	// error, too many arguments
    +	int[] x;
    +	test(x);	// error, type mismatch
    +	

    + +

    Local Variables

    It is an error to use a local variable without first assigning it a value. The implementation may not always be able to detect these @@ -828,6 +1001,20 @@
    Copyright © 1999-2005 by Digital Mars, All Rights Reserved

    + + + + + diff -uNr dmd-0.125/dmd/html/d/future.html dmd-0.126/dmd/html/d/future.html --- dmd-0.125/dmd/html/d/future.html 2005-05-19 11:44:48.000000000 +0200 +++ dmd-0.126/dmd/html/d/future.html 2005-05-19 15:08:50.000000000 +0200 @@ -28,7 +28,7 @@ D Programming Language - Future Directions - + www.digitalmars.com @@ -61,6 +61,20 @@


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

    + + + + + diff -uNr dmd-0.125/dmd/html/d/garbage.html dmd-0.126/dmd/html/d/garbage.html --- dmd-0.125/dmd/html/d/garbage.html 2005-05-19 11:44:48.000000000 +0200 +++ dmd-0.126/dmd/html/d/garbage.html 2005-05-19 15:08:50.000000000 +0200 @@ -28,7 +28,7 @@ D Programming Language - Garbage Collection - + www.digitalmars.com @@ -356,6 +356,20 @@


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

    + + + + + diff -uNr dmd-0.125/dmd/html/d/html.html dmd-0.126/dmd/html/d/html.html --- dmd-0.125/dmd/html/d/html.html 2005-05-19 11:44:48.000000000 +0200 +++ dmd-0.126/dmd/html/d/html.html 2005-05-19 15:08:50.000000000 +0200 @@ -28,7 +28,7 @@ D Programming Language - Embedding D in HTML - + www.digitalmars.com @@ -99,6 +99,20 @@


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

    + + + + + diff -uNr dmd-0.125/dmd/html/d/htomodule.html dmd-0.126/dmd/html/d/htomodule.html --- dmd-0.125/dmd/html/d/htomodule.html 2005-05-19 11:44:48.000000000 +0200 +++ dmd-0.126/dmd/html/d/htomodule.html 2005-05-19 15:08:50.000000000 +0200 @@ -28,7 +28,7 @@ D Programming Language - Converting C .h Files to D Modules - + www.digitalmars.com @@ -508,6 +508,20 @@


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

    + + + + + diff -uNr dmd-0.125/dmd/html/d/iasm.html dmd-0.126/dmd/html/d/iasm.html --- dmd-0.125/dmd/html/d/iasm.html 2005-05-19 11:44:48.000000000 +0200 +++ dmd-0.126/dmd/html/d/iasm.html 2005-05-19 15:08:50.000000000 +0200 @@ -28,7 +28,7 @@ D Programming Language - Inline Assembler - + www.digitalmars.com @@ -1106,6 +1106,20 @@


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

    + + + + + diff -uNr dmd-0.125/dmd/html/d/index.html dmd-0.126/dmd/html/d/index.html --- dmd-0.125/dmd/html/d/index.html 2002-10-07 01:24:36.000000000 +0200 +++ dmd-0.126/dmd/html/d/index.html 2005-05-21 12:59:28.000000000 +0200 @@ -1,4 +1,5 @@ - + + - - D Programming Language - - + + + D Programming Language + + + - - - - - - <body> - <ul> - <li> <a href="toc.html">Table of Contents</a> - <li> <a href="intro.html">Introduction to D</a> - </ul> - </body> - + + - + + <body> + <ul> + <li><a href="toc.html">Table of Contents</a></li> + <li><a href="intro.html">Introduction to D</a></li> + </ul> + </body> + + + \ No newline at end of file diff -uNr dmd-0.125/dmd/html/d/interface.html dmd-0.126/dmd/html/d/interface.html --- dmd-0.125/dmd/html/d/interface.html 2005-05-19 11:44:48.000000000 +0200 +++ dmd-0.126/dmd/html/d/interface.html 2005-06-06 18:19:50.000000000 +0200 @@ -25,10 +25,10 @@ -D Programming Language - Interfacing to C +D Programming Language - Interfaces - + www.digitalmars.com @@ -37,368 +37,198 @@ | D
    -Last update Thu May 19 2005 +Last update Mon Jun 06 2005


    +

    Interfaces

    -

    Interfacing to C

    - - D is designed to fit comfortably with a C compiler for the target - system. D makes up for not having its own VM by relying on the - target environment's C runtime library. It would be senseless to - attempt to port to D or write D wrappers for the vast array of C APIs - available. How much easier it is to just call them directly. -

    - - This is done by matching the C compiler's data types, layouts, - and function call/return sequences. +

    +
    +
    
    +	InterfaceDeclaration:
    +		interface Identifier InterfaceBody
    +		interface Identifier : SuperInterfaces InterfaceBody
    +
    +	SuperInterfaces
    +		Identifier
    +		Identifier , SuperInterfaces
     
    -

    Calling C Functions

    + InterfaceBody: + { DeclDefs } +

    - C functions can be called directly from D. There is no need for - wrapper functions, argument swizzling, and the C functions do not - need to be put into a separate DLL. + Interfaces describe a list of functions that a class that inherits + from the interface must implement. + A class that implements an interface can be converted to a reference + to that interface. Interfaces correspond to the interface exposed + by operating system objects, like COM/OLE/ActiveX for Win32.

    - The C function must be declared and given a calling convention, - most likely the "C" calling convention, for example: + Interfaces cannot derive from classes; only from other interfaces. + Classes cannot derive from an interface multiple times.

    
    -	extern (C) int strcmp(char* string1, char* string2);
    +	interface D
    +	{
    +	    void foo();
    +	}
    +
    +	class A : D, D	// error, duplicate interface
    +	{
    +	}
     	

    - and then it can be called within D code in the obvious way: + An instance of an interface cannot be created. +

    
    -	import std.string;
    -	int myDfunction(char[] s)
    +	interface D
     	{
    -	    return strcmp(std.string.toStringz(s), "foo");
    +	    void foo();
     	}
    -	

    - There are several things going on here: + ... -

      -
    • D understands how C function names are "mangled" and the - correct C function call/return sequence. + D d = new D(); // error, cannot create instance of interface +

    -

  15. C functions cannot be overloaded with another C function - with the same name. + Interface member functions do not have implementations. -
  16. There are no __cdecl, __far, __stdcall, __declspec, or other - such C type modifiers in D. These are handled by attributes, such - as extern (C). - -
  17. There are no const or volatile type modifiers in D. To declare - a C function that uses those type modifiers, just drop those - keywords from the declaration. - -
  18. Strings are not 0 terminated in D. See "Data Type Compatibility" - for more information about this. However, string literals in D are - 0 terminated. - +

    +
    +
    
    +	interface D
    +	{
    +	    void bar() { }	// error, implementation not allowed
    +	}
    +	

    - C code can correspondingly call D functions, if the D functions - use an attribute that is compatible with the C compiler, most likely - the extern (C): + All interface functions must be defined in a class that inherits + from that interface:

    
    -	// myfunc() can be called from any C function
    -	extern (C)
    +	interface D
     	{
    -	    void myfunc(int a, int b)
    -	    {
    -		...
    -	    }
    +	    void foo();
     	}
    -	

    -

    Storage Allocation

    + class A : D + { + void foo() { } // ok, provides implementation + } - C code explicitly manages memory with calls to malloc() and - free(). D allocates memory using the D garbage collector, - so no explicit free's are necessary. -

    + class B : D + { + int foo() { } // error, no void foo() implementation + } +

  19. - D can still explicitly allocate memory using c.stdlib.malloc() - and c.stdlib.free(), these are useful for connecting to C - functions that expect malloc'd buffers, etc. -

    + Interfaces can be inherited and functions overridden: - If pointers to D garbage collector allocated memory are passed to - C functions, it's critical to ensure that that memory will not - be collected by the garbage collector before the C function is - done with it. This is accomplished by: +

    +
    +
    
    +	interface D
    +	{
    +	    int foo();
    +	}
     
    -	
      + class A : D + { + int foo() { return 1; } + } -
    • Making a copy of the data using c.stdlib.malloc() and passing - the copy instead. + class B : A + { + int foo() { return 2; } + } -
    • Leaving a pointer to it on the stack (as a parameter or - automatic variable), as the garbage collector will scan the stack. + ... -
    • Leaving a pointer to it in the static data segment, as the - garbage collector will scan the static data segment. + B b = new B(); + b.foo(); // returns 2 + D d = (D) b; // ok since B inherits A's D implementation + d.foo(); // returns 2; +

    -

  20. Registering the pointer with the garbage collector with the - gc.addRoot() or gc.addRange() calls. + Interfaces can be reimplemented in derived classes: - +

    +
    +
    
    +	interface D
    +	{
    +	    int foo();
    +	}
     
    -	An interior pointer to the allocated memory block is sufficient
    -	to let the GC
    -	know the object is in use; i.e. it is not necessary to maintain
    -	a pointer to the beginning of the allocated memory.
    -	

    + class A : D + { + int foo() { return 1; } + } - The garbage collector does not scan the stacks of threads not - created by the D Thread interface. Nor does it scan the data - segments of other DLL's, etc. - -

    Data Type Compatibility

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    D typeC type
    voidvoid
    bitno equivalent
    bytesigned char
    ubyteunsigned char
    charchar (chars are unsigned in D)
    wcharwchar_t (when sizeof(wchar_t) is 2)
    dcharwchar_t (when sizeof(wchar_t) is 4)
    shortshort
    ushortunsigned short
    intint
    uintunsigned
    longlong long
    ulongunsigned long long
    floatfloat
    doubledouble
    reallong double
    ifloatfloat _Imaginary
    idoubledouble _Imaginary
    ireallong double _Imaginary
    cfloatfloat _Complex
    cdoubledouble _Complex
    creallong double _Complex
    structstruct
    unionunion
    enumenum
    classno equivalent
    type*type *
    type[dim]type[dim]
    type[dim]*type(*)[dim]
    type[]no equivalent
    type[type]no equivalent
    type function(parameters)type(*)(parameters)
    type delegate(parameters)no equivalent
    -

    + class B : A, D + { + int foo() { return 2; } + } - These equivalents hold for most 32 bit C compilers. The C standard - does not pin down the sizes of the types, so some care is needed. + ... -

    Calling printf()

    + B b = new B(); + b.foo(); // returns 2 + D d = (D) b; + d.foo(); // returns 2 + A a = (A) b; + D d2 = (D) a; + d2.foo(); // returns 2, even though it is A's D, not B's D +

    - This mostly means checking that the printf format specifier - matches the corresponding D data type. - Although printf is designed to handle 0 terminated strings, - not D dynamic arrays of chars, it turns out that since D - dynamic arrays are a length followed by a pointer to the data, - the %.*s format works perfectly: + A reimplemented interface must implement all the interface + functions, it does not inherit them from a super class:

    
    -	void foo(char[] string)
    +	interface D
     	{
    -	    printf("my string is: %.*s\n", string);
    +	    int foo();
     	}
    -	

    - The printf format string literal - in the example doesn't end with \0. This is because string literals, - when they are not part of an initializer to a larger data structure, - have a \0 character helpfully stored after the end of them. -

    + class A : D + { + int foo() { return 1; } + } - An improved D function for formatted output is - std.stdio.writef(). + class B : A, D + { + } // error, no foo() for interface D +

  21. -

    Structs and Unions

    +

    COM Interfaces

    - D structs and unions are analogous to C's. + A variant on interfaces is the COM interface. A COM interface is + designed to map directly onto a Windows COM object. Any COM object + can be represented by a COM interface, and any D object with + a COM interface can be used by external COM clients.

    - C code often adjusts the alignment and packing of struct members - with a command line switch or with various implementation specific - #pragma's. D supports explicit alignment attributes that correspond - to the C compiler's rules. Check what alignment the C code is using, - and explicitly set it for the D struct declaration. -

    + A COM interface is defined as one that derives from the interface + std.c.windows.com.IUnknown. A COM interface differs from + a regular D interface in that: - D does not support bit fields. If needed, they can be emulated - with shift and mask operations. - -


    Interfacing to C++

    - - D does not provide an interface to C++. Since D, however, - interfaces directly to C, it can interface directly to - C++ code if it is declared as having C linkage. -

    - - D class objects are incompatible with C++ class objects. +

      +
    • It derives from the interface std.c.windows.com.IUnknown. +
    • It cannot be the argument of a DeleteExpression. +
    • References cannot be upcast to the enclosing class object, nor + can they be downcast to a derived interface. To accomplish this, + an appropriate QueryInterface() would have to be implemented + for that interface in standard COM fashion. +

    Feedback and Comments

    @@ -409,6 +239,20 @@
    Copyright © 1999-2005 by Digital Mars, All Rights Reserved

    + + + + + diff -uNr dmd-0.125/dmd/html/d/intro.html dmd-0.126/dmd/html/d/intro.html --- dmd-0.125/dmd/html/d/intro.html 2005-05-19 11:44:48.000000000 +0200 +++ dmd-0.126/dmd/html/d/intro.html 2005-05-22 10:46:58.000000000 +0200 @@ -1,20 +1,5 @@ - - - - - - - - - - - - - - - - + + - -D Programming Language + + D Programming Language + + - - -www.digitalmars.com -Home -| Search -| D - -
    -Last update Thu May 19 2005 -


    - -

    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 myself as a reengineering of C and C++, -and has grown and evolved with helpful -suggestions and critiques by my friends and colleagues. -I've been told the usual, that there's no chance for a new programming -language, that who do I think I am designing a language, etc. Take a -look at the document and decide for yourself! -

    - - 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. -

    +

    + www.digitalmars.com + + Home + | Search + | D + +
    Last update Thu May 19 2005
    +
    + +

    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 myself as a reengineering of C and C++, + and has grown and evolved with helpful + suggestions and critiques by my friends and colleagues. + I've been told the usual, that there's no chance for a new programming + language, that who do I think I am designing a language, etc. Take a + look at the document and decide for yourself!

    + +

    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" -

    - For SDWest 2004 I gave a +

    For SDWest 2004 I gave a - presentation on D. -

    + presentation on D.

    - Do you feel the - need for speed? -

    +

    Do you feel the + need for speed?

    - Note: all D users agree that by downloading and using +

    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. -

    --Walter + feedback sent to Digital Mars.

    + + -Walter + -

    Feedback and Comments

    +

    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.125/dmd/html/d/lex.html dmd-0.126/dmd/html/d/lex.html --- dmd-0.125/dmd/html/d/lex.html 2005-05-19 11:44:48.000000000 +0200 +++ dmd-0.126/dmd/html/d/lex.html 2005-05-19 15:08:50.000000000 +0200 @@ -28,7 +28,7 @@ D Programming Language - Lexical - + www.digitalmars.com @@ -938,6 +938,20 @@


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

    + + + + + diff -uNr dmd-0.125/dmd/html/d/memory.html dmd-0.126/dmd/html/d/memory.html --- dmd-0.125/dmd/html/d/memory.html 2005-05-19 11:44:48.000000000 +0200 +++ dmd-0.126/dmd/html/d/memory.html 2005-06-01 15:01:32.000000000 +0200 @@ -28,7 +28,7 @@ D Programming Language - Memory Management - + www.digitalmars.com @@ -37,7 +37,7 @@ | D
    -Last update Thu May 19 2005 +Last update Wed Jun 01 2005


    @@ -516,28 +516,19 @@ 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 - the following idiom: + a VoidInitializer:

    
    -	import std.c.stdlib;
    -
     	void foo()
    -	{   byte[] buffer = (cast(byte*)std.c.stdlib.alloca(1024))[0 .. 1024];
    +	{   byte[1024] buffer = void;
     
     	    fillBuffer(buffer);
     	    ...
     	}
     	

    - A good D implementation will recognize that alloca() is called with - a constant size argument, and so can be replaced with an uninitialized - array of the same size allocated on the stack. This will produce - execution performance equivalent to using an uninitialized stack - array in C. -

    - Uninitialized data on the stack comes with some caveats that need to be carefully evaluated before using: @@ -576,6 +567,20 @@


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

    + + + + + diff -uNr dmd-0.125/dmd/html/d/mixin.html dmd-0.126/dmd/html/d/mixin.html --- dmd-0.125/dmd/html/d/mixin.html 2005-05-19 11:44:48.000000000 +0200 +++ dmd-0.126/dmd/html/d/mixin.html 2005-05-19 15:08:50.000000000 +0200 @@ -28,7 +28,7 @@ D Programming Language - Mixins - + www.digitalmars.com @@ -352,6 +352,20 @@


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

    + + + + + diff -uNr dmd-0.125/dmd/html/d/module.html dmd-0.126/dmd/html/d/module.html --- dmd-0.125/dmd/html/d/module.html 2005-05-19 11:44:48.000000000 +0200 +++ dmd-0.126/dmd/html/d/module.html 2005-05-19 15:08:50.000000000 +0200 @@ -28,7 +28,7 @@ D Programming Language - Modules - + www.digitalmars.com @@ -313,6 +313,20 @@


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

    + + + + + diff -uNr dmd-0.125/dmd/html/d/operatoroverloading.html dmd-0.126/dmd/html/d/operatoroverloading.html --- dmd-0.125/dmd/html/d/operatoroverloading.html 2005-05-19 11:44:48.000000000 +0200 +++ dmd-0.126/dmd/html/d/operatoroverloading.html 2005-05-19 15:08:50.000000000 +0200 @@ -28,7 +28,7 @@ D Programming Language - Operator Overloading - + www.digitalmars.com @@ -600,6 +600,20 @@


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

    + + + + + diff -uNr dmd-0.125/dmd/html/d/overview.html dmd-0.126/dmd/html/d/overview.html --- dmd-0.125/dmd/html/d/overview.html 2005-05-19 11:44:48.000000000 +0200 +++ dmd-0.126/dmd/html/d/overview.html 2005-05-19 15:08:48.000000000 +0200 @@ -28,7 +28,7 @@ Digital Mars - The D Programming Language - + www.digitalmars.com @@ -951,6 +951,20 @@


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

    + + + + + diff -uNr dmd-0.125/dmd/html/d/phobos.html dmd-0.126/dmd/html/d/phobos.html --- dmd-0.125/dmd/html/d/phobos.html 2005-05-19 11:44:48.000000000 +0200 +++ dmd-0.126/dmd/html/d/phobos.html 2005-06-07 21:54:28.000000000 +0200 @@ -28,7 +28,7 @@ D Programming Language - Phobos Runtime Library - + www.digitalmars.com @@ -37,7 +37,7 @@ | D
    -Last update Thu May 19 2005 +Last update Tue Jun 07 2005


    @@ -240,6 +240,9 @@
    std.stdio
    Standard I/O. +
    std.cstream +
    Stream I/O. +
    std.stream
    Stream I/O. @@ -2863,6 +2866,20 @@
    Copyright © 1999-2005 by Digital Mars, All Rights Reserved

    + + + + + diff -uNr dmd-0.125/dmd/html/d/portability.html dmd-0.126/dmd/html/d/portability.html --- dmd-0.125/dmd/html/d/portability.html 2005-05-19 11:44:48.000000000 +0200 +++ dmd-0.126/dmd/html/d/portability.html 2005-05-19 15:08:50.000000000 +0200 @@ -28,7 +28,7 @@ D Programming Language - Portability - + www.digitalmars.com @@ -138,6 +138,20 @@


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

    + + + + + diff -uNr dmd-0.125/dmd/html/d/pragma.html dmd-0.126/dmd/html/d/pragma.html --- dmd-0.125/dmd/html/d/pragma.html 2005-05-19 11:44:48.000000000 +0200 +++ dmd-0.126/dmd/html/d/pragma.html 2005-05-19 15:08:50.000000000 +0200 @@ -28,7 +28,7 @@ D Programming Language - Pragmas - + www.digitalmars.com @@ -149,6 +149,20 @@


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

    + + + + + diff -uNr dmd-0.125/dmd/html/d/pretod.html dmd-0.126/dmd/html/d/pretod.html --- dmd-0.125/dmd/html/d/pretod.html 2005-05-19 11:44:48.000000000 +0200 +++ dmd-0.126/dmd/html/d/pretod.html 2005-05-19 15:08:48.000000000 +0200 @@ -28,7 +28,7 @@ Digital Mars - The C Preprocessor vs D - + www.digitalmars.com @@ -737,6 +737,20 @@


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

    + + + + + diff -uNr dmd-0.125/dmd/html/d/property.html dmd-0.126/dmd/html/d/property.html --- dmd-0.125/dmd/html/d/property.html 2005-05-19 11:44:48.000000000 +0200 +++ dmd-0.126/dmd/html/d/property.html 2005-05-19 15:08:50.000000000 +0200 @@ -28,7 +28,7 @@ D Programming Language - Properties - + www.digitalmars.com @@ -179,6 +179,20 @@


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

    + + + + + diff -uNr dmd-0.125/dmd/html/d/statement.html dmd-0.126/dmd/html/d/statement.html --- dmd-0.125/dmd/html/d/statement.html 2005-05-19 11:44:48.000000000 +0200 +++ dmd-0.126/dmd/html/d/statement.html 2005-06-01 14:50:06.000000000 +0200 @@ -28,7 +28,7 @@ D Programming Language - Statements - + www.digitalmars.com @@ -37,7 +37,7 @@ | D
    -Last update Thu May 19 2005 +Last update Wed Jun 01 2005


    @@ -190,10 +190,10 @@ Variable: Identifier - Identifier = AssignmentExpression + Identifier = Initializer

    - If no AssignmentExpression is there to initialize the + If no Initializer is there to initialize the variable, it is initialized to the default value for its type.

    If Statement

    @@ -1190,6 +1190,20 @@
    Copyright © 1999-2005 by Digital Mars, All Rights Reserved

    + + + + + diff -uNr dmd-0.125/dmd/html/d/std_boxer.html dmd-0.126/dmd/html/d/std_boxer.html --- dmd-0.125/dmd/html/d/std_boxer.html 2005-05-19 11:44:48.000000000 +0200 +++ dmd-0.126/dmd/html/d/std_boxer.html 2005-05-19 15:08:50.000000000 +0200 @@ -28,7 +28,7 @@ Phobos Runtime Library - std.boxer - + www.digitalmars.com diff -uNr dmd-0.125/dmd/html/d/std_cstream.html dmd-0.126/dmd/html/d/std_cstream.html --- dmd-0.125/dmd/html/d/std_cstream.html 1970-01-01 01:00:00.000000000 +0100 +++ dmd-0.126/dmd/html/d/std_cstream.html 2005-06-03 18:28:56.000000000 +0200 @@ -0,0 +1,77 @@ + + + + + + +Digital Mars - Phobos - std.cstream + + + +www.digitalmars.com + +[Home] +[Search] +[D] + +
    Last update Apr 21, 2005 +


    + +

    Phobos: 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). +
    + + +
    Copyright (c) 2004-2005 by Digital Mars, All Rights Reserved + + + + + + diff -uNr dmd-0.125/dmd/html/d/std_stream.html dmd-0.126/dmd/html/d/std_stream.html --- dmd-0.125/dmd/html/d/std_stream.html 2005-05-03 16:04:00.000000000 +0200 +++ dmd-0.126/dmd/html/d/std_stream.html 2005-06-03 18:29:28.000000000 +0200 @@ -122,6 +122,8 @@
    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) @@ -273,6 +275,11 @@ 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. diff -uNr dmd-0.125/dmd/html/d/struct.html dmd-0.126/dmd/html/d/struct.html --- dmd-0.125/dmd/html/d/struct.html 2005-05-19 11:44:48.000000000 +0200 +++ dmd-0.126/dmd/html/d/struct.html 2005-05-19 15:08:50.000000000 +0200 @@ -28,7 +28,7 @@ D Programming Language - Structs, Unions - + www.digitalmars.com @@ -153,6 +153,20 @@
    Copyright © 1999-2005 by Digital Mars, All Rights Reserved

    + + + + + diff -uNr dmd-0.125/dmd/html/d/style.css dmd-0.126/dmd/html/d/style.css --- dmd-0.125/dmd/html/d/style.css 1970-01-01 01:00:00.000000000 +0100 +++ dmd-0.126/dmd/html/d/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; +} \ No newline at end of file diff -uNr dmd-0.125/dmd/html/d/template.html dmd-0.126/dmd/html/d/template.html --- dmd-0.125/dmd/html/d/template.html 2005-05-19 11:44:48.000000000 +0200 +++ dmd-0.126/dmd/html/d/template.html 2005-05-19 15:08:50.000000000 +0200 @@ -28,7 +28,7 @@ D Programming Language - Templates - + www.digitalmars.com @@ -706,6 +706,20 @@


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

    + + + + + diff -uNr dmd-0.125/dmd/html/d/toc.html dmd-0.126/dmd/html/d/toc.html --- dmd-0.125/dmd/html/d/toc.html 2005-05-15 12:47:18.000000000 +0200 +++ dmd-0.126/dmd/html/d/toc.html 2005-06-06 17:58:12.000000000 +0200 @@ -1,112 +1,126 @@ - + + + + -D Programming Language - + + D Programming Language + + + + - - + - -

    The
    -
    D
    -
    Programming
    -
    Language
    -
    -
    - - -· Introduction
    -· Overview
    -· 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
    -· Phobos (Runtime Library)
    -· 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
    - -
    -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++
    - -
    -Community
    -· News Digest
    -· News
    -· Forum
    -· Announcements
    -· Learn
    -· D links
    - - -
    -Archives
    -· digitalmars.D
    -· digitalmars.D.dtl
    -· digitalmars.D.bugs
    -· D.gnu
    -· Old D
    +
    + The
    + D
    + Programming
    + Language
    +
    + + + + Tools + + + Comparisons + + + Community + + + Archives + -
    +
    Copyright © 1999-2005 by Digital Mars, All Rights Reserved
    -
    Copyright © 1999-2005 by Digital Mars, All Rights Reserved

    - - diff -uNr dmd-0.125/dmd/html/d/type.html dmd-0.126/dmd/html/d/type.html --- dmd-0.125/dmd/html/d/type.html 2005-05-19 11:44:48.000000000 +0200 +++ dmd-0.126/dmd/html/d/type.html 2005-05-19 15:08:50.000000000 +0200 @@ -28,7 +28,7 @@ D Programming Language - Types - + www.digitalmars.com @@ -300,6 +300,20 @@


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

    + + + + + diff -uNr dmd-0.125/dmd/html/d/version.html dmd-0.126/dmd/html/d/version.html --- dmd-0.125/dmd/html/d/version.html 2005-05-19 11:44:48.000000000 +0200 +++ dmd-0.126/dmd/html/d/version.html 2005-05-25 23:52:40.000000000 +0200 @@ -28,7 +28,7 @@ D Programming Language - Conditional Compilation - + www.digitalmars.com @@ -37,7 +37,7 @@ | D
    -Last update Thu May 19 2005 +Last update Wed May 25 2005


    @@ -48,7 +48,9 @@ (In C and C++, conditional compilation is done with the preprocessor directives #if / #else / #endif.) -
    +	

    +
    +
    
     	ConditionalDeclaration:
     	    Condition DeclarationBlock
     	    Condition DeclarationBlock else DeclarationBlock
    @@ -64,7 +66,7 @@
     	ConditionalStatement:
     	    Condition Statement
     	    Condition Statement else Statement
    -	
    +

    If the Condition is satisfied, then the following DeclarationBlock or Statement is compiled in. @@ -91,13 +93,15 @@ Condition comes in the following forms: -

    +	

    +
    +
    
     	Condition:
     	    VersionCondition
     	    DebugCondition
     	    StaticIfCondition
     	    IfTypeCondition
    -	
    +

    Version Condition

    @@ -105,11 +109,13 @@ with a single source file.

    -

    +	

    +
    +
    
     	VersionCondition:
     		version ( Integer )
     		version ( Identifier )
    -	
    +

    The VersionCondition is satisfied if the Integer is greater than or equal to the current version level, @@ -155,11 +161,13 @@

    Version Specification

    -
    +	

    +
    +
    
     	VersionSpecification
     	    version = Identifier ;
     	    version = Integer ;
    -	
    +

    The version specification makes it straightforward to group a set of features under one major version, for example: @@ -316,12 +324,14 @@ It is D's way of what in C is done with #ifdef DEBUG / #endif pairs. -

    +	

    +
    +
    
     	DebugCondition:
     	    debug
     	    debug ( Integer )
     	    debug ( Identifier )
    -	
    +

    The debug condition is satisfied when the -debug switch is thrown on the compiler. @@ -350,11 +360,13 @@

    Debug Specification

    -
    +	

    +
    +
    
     	DebugSpecification
     	    debug = Identifier ;
     	    debug = Integer ;
    -	
    +

    Debug identifiers and levels are set either by the command line switch -debug or by a DebugSpecification. @@ -389,10 +401,12 @@

    Static If Condition

    -
    +	

    +
    +
    
     	StaticIfCondition:
     	    static if ( AssignExpression )
    -	
    +

    AssignExpression is implicitly converted to a boolean type, and is evaluated at compile time. @@ -467,23 +481,46 @@

    Iftype Condition

    -
    +	

    +
    +
    
     	IftypeCondition:
    +	    iftype ( Type )
     	    iftype ( Type : TypeSpecialization )
    +	    iftype ( Type == TypeSpecialization )
     	    iftype ( Type Identifier )
     	    iftype ( Type Identifier : TypeSpecialization )
    +	    iftype ( Type Identifier == TypeSpecialization )
     
     	TypeSpecialization:
     	    Type
    -	
    +

    IftypeCondition is analogous to StaticIfCondition except that it is for types rather than expressions. - There are three forms, corresponding to the three definitions above: + There are several forms, corresponding to the three definitions above:

      -
    1. The condition is satisfied if Type is the same as +
    2. 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()
      +	{
      +	    iftype (func[])	// not satisfied because arrays of
      +				// functions are not allowed
      +		printf("satisfied\n");
      +	    else
      +		printf("not satisfied\n");
      +	}
      +	

      + +

    3. The condition is satisfied if Type is semantically + correct and it is the same as or can be implicitly converted to TypeSpecialization. @@ -491,7 +528,7 @@
      
       	alias short bar;
      -	int foo(bar x)
      +	void foo(bar x)
       	{
       	    iftype (bar : int)	// satisfied because short can be
       				// implicitly converted to int
      @@ -501,14 +538,18 @@
       	}
       	

      -

    4. The condition is always satisfied, and Identifier +
    5. The condition is satisfied if Type is semantically + correct and is the same type as TypeSpecialization. + +
    6. The condition is satisfied if Type is semantically + correct. If so, Identifier is declared to be an alias of Type.

      
       	alias short bar;
      -	int foo(bar x)
      +	void foo(bar x)
       	{
       	    iftype (bar T)
       		alias T S;
      @@ -530,7 +571,7 @@
       	
      
       	alias short bar;
       	alias long* abc;
      -	int foo(bar x, abc a)
      +	void foo(bar x, abc a)
       	{
       	    iftype (bar T : int)
       		alias T S;
      @@ -550,14 +591,22 @@
       	to the way template parameter types are determined by
       	TemplateTypeParameterSpecialization.
       
      +	
    7. The condition is satisfied if Type is semantically + correct and is the same as TypeSpecialization. + The Identifier is declared to be either an alias of the + TypeSpecialization or, if TypeSpecialization is + dependent on Identifier, the deduced type. +

      Static Assert

      -
      +	

      +
      +
      
       	StaticAssert:
       	    static assert ( Expression );
      -	
      +

      Expression is evaluated at compile time, and converted to a boolean value. If the value is true, the static assert @@ -601,6 +650,20 @@


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

      + + + + + diff -uNr dmd-0.125/dmd/html/d/wc.html dmd-0.126/dmd/html/d/wc.html --- dmd-0.125/dmd/html/d/wc.html 2005-05-19 11:44:48.000000000 +0200 +++ dmd-0.126/dmd/html/d/wc.html 2005-05-22 10:46:58.000000000 +0200 @@ -1,20 +1,5 @@ - - - - - - - - - - - - - - - - + + - -D Programming Language - wc Example + + D Programming Language + + - - -www.digitalmars.com -Home -| Search -| D +

      + www.digitalmars.com -
      -Last update Thu May 19 2005 -
      + Home + | Search + | D +
      Last update Thu May 19 2005
      +
      -

      Example: wc

      +

      Example: wc

      -This program is the D version of the classic wc (wordcount) C program. -It serves to demonstrate how to read files, slice arrays, -and simple symbol table management with associative arrays. +

      This program is the D version of the classic wc (wordcount) C program. + It serves to demonstrate how to read files, slice arrays, + and simple symbol table management with associative arrays.

      -

      -
      -
      
      -import std.file;
      +	
      import std.file;
       
       int main (char[][] args)
       {
      @@ -94,20 +76,30 @@
       	    l_total, w_total, c_total);
           }
           return 0;
      -}
      -

      +}

      -

      Feedback and Comments

      - Add Feedback and Comments + +

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

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

      - - - diff -uNr dmd-0.125/dmd/html/d/windows.html dmd-0.126/dmd/html/d/windows.html --- dmd-0.125/dmd/html/d/windows.html 2005-05-19 11:44:48.000000000 +0200 +++ dmd-0.126/dmd/html/d/windows.html 2005-05-19 15:08:50.000000000 +0200 @@ -28,7 +28,7 @@ D Programming Language - Windows - + www.digitalmars.com @@ -184,6 +184,20 @@


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

      + + + + +