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 @@
@@ -206,6 +206,20 @@
+ + + + +
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 @@
@@ -82,6 +82,20 @@
+ + + + +
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 @@
@@ -37,7 +37,7 @@
| D
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 @@
+ + + + +
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 @@
@@ -476,6 +476,20 @@
+ + + + +
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 @@ - - - - - - - - - - - - - - - - - - - - - -
-
-Home
-| Search
-| D
-
-- -
- -
- -
- -
- -
- -
---
-- replace uint buffer lengths with size_t -
- add line-by-line opApply to Stream and InputStream (due to Regan - Heath)
- int opApply(int delegate(inout char[] line) dg)
- int opApply(int delegate(inout ulong n, inout char[] line) dg)
- int opApply(int delegate(inout wchar[] line) dg)
- int opApply(int delegate(inout ulong n, inout wchar[] line) dg) -- move readable/writeable/seekable tests from contracts to the body - since phobos is compiled in release mode and users can easily try - to write to an unwritable stream -
- return "this" from writef and writefln to allow chaining (eg flush) -
- fix TArrayStream read/write to check for "eof" (Derick Eddington) -
- make SliceStream preserve the source buffer position if seekable - and pay attention to isOpen (Derick) -
- implement available() for more stream types (Derick) -
- copyFrom bug fixes and position preserving if seekable (Derick) -
- move the initialization of the BOMs to the initializer instead of the - module constructor. -
- make isopen protected (from private) so that subclasses can see it. -
- more unittest (Derick and Ben) -
- fix File.size() bug on Windows -
- fix File.open() error message to say "Cannot open or create file" -
- -
- -
- -
- -
- module foo.bar;- then bar is not in scope, one must use foo.bar. -
- -
- -
- IPv6 not supported but the C interface for it should all be there. - Split up socket.d and put the C stuff in std.c modules. - std.c.linux.linux updated because most of the socket functions - are actually regular I/O functions. Added classes Protocol and Service. - Added Socket.accepting() to allow derived classes to be - accepted. - Documentation and samples updated. - Fixed major bug in the linux version. -- -
- -
- -Note: This is a library only change, the dmd executables are still -at 0.111. - -
- I've attached modified versions of std.stream and mmfile and the help - section for std.mmfile and std.stream. - The std.mmfile changes are: ---
- The std.stream changes are: -- change module declaration to std.mmfile -
- change class declaration to not be auto -
- add mMode read-only property to get the file mode of type MmFile.Mode -
-
-- added Dave Fladebo's performance improvements for buffered readLine -
- fixed a bug in read/write cfloat/cdouble/creal endian support -
- uncommented MmFileStream and cleaned it up to use MmFile's mode property. -
- template foo(T:T[]) -- now correctly resolve T in foo(int[]) to int rather than int[]. -
- char[][] foo; - foo = new char[][45]; // new, correct way to allocate array of 45 strings - //foo = new char[45][]; // old, now wrong, way --
- int[3][4] a; // a is 4 arrays of 3 arrays of ints - int b[4][3]; // b is 4 arrays of 3 arrays of ints --
- byte b = 0x10; // ok - ubyte c = 0x100; // error - byte d = 0x80; // error - ubyte e = 0x80; // ok --
- -
- - - - + + + + + + + + + + + + + + + + + + + + + +
+
+Home
+| Search
+| D
+
++ +
+ +
+ +
+ +
+ +
+ +
+ +
+++
+- replace uint buffer lengths with size_t +
- add line-by-line opApply to Stream and InputStream (due to Regan + Heath)
+ int opApply(int delegate(inout char[] line) dg)
+ int opApply(int delegate(inout ulong n, inout char[] line) dg)
+ int opApply(int delegate(inout wchar[] line) dg)
+ int opApply(int delegate(inout ulong n, inout wchar[] line) dg) +- move readable/writeable/seekable tests from contracts to the body + since phobos is compiled in release mode and users can easily try + to write to an unwritable stream +
- return "this" from writef and writefln to allow chaining (eg flush) +
- fix TArrayStream read/write to check for "eof" (Derick Eddington) +
- make SliceStream preserve the source buffer position if seekable + and pay attention to isOpen (Derick) +
- implement available() for more stream types (Derick) +
- copyFrom bug fixes and position preserving if seekable (Derick) +
- move the initialization of the BOMs to the initializer instead of the + module constructor. +
- make isopen protected (from private) so that subclasses can see it. +
- more unittest (Derick and Ben) +
- fix File.size() bug on Windows +
- fix File.open() error message to say "Cannot open or create file" +
+ +
+ +
+ +
+ +
+ module foo.bar;+ then bar is not in scope, one must use foo.bar. +
+ +
+ +
+ IPv6 not supported but the C interface for it should all be there. + Split up socket.d and put the C stuff in std.c modules. + std.c.linux.linux updated because most of the socket functions + are actually regular I/O functions. Added classes Protocol and Service. + Added Socket.accepting() to allow derived classes to be + accepted. + Documentation and samples updated. + Fixed major bug in the linux version. ++ +
+ +
+ +Note: This is a library only change, the dmd executables are still +at 0.111. + +
+ I've attached modified versions of std.stream and mmfile and the help + section for std.mmfile and std.stream. + The std.mmfile changes are: +++
+ The std.stream changes are: +- change module declaration to std.mmfile +
- change class declaration to not be auto +
- add mMode read-only property to get the file mode of type MmFile.Mode +
+
+- added Dave Fladebo's performance improvements for buffered readLine +
- fixed a bug in read/write cfloat/cdouble/creal endian support +
- uncommented MmFileStream and cleaned it up to use MmFile's mode property. +
+ template foo(T:T[]) ++ now correctly resolve T in foo(int[]) to int rather than int[]. +
+ char[][] foo; + foo = new char[][45]; // new, correct way to allocate array of 45 strings + //foo = new char[45][]; // old, now wrong, way ++
+ int[3][4] a; // a is 4 arrays of 3 arrays of ints + int b[4][3]; // b is 4 arrays of 3 arrays of ints ++
+ byte b = 0x10; // ok + ubyte c = 0x100; // error + byte d = 0x80; // error + ubyte e = 0x80; // ok ++
+ + + + + +
+ + + + 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 @@
@@ -37,7 +37,7 @@
| D
+
+
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;
-
+ |
+ +
+
class Foo
{
int x;
@@ -179,7 +209,7 @@
o = Foo.x.offsetof; // yields 8
o = foo.x.offsetof; // error, .offsetof an int type
}
-
+ |
+
+ 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:
+ +
+
this() { this(1); }
this(int i) { this(); } // illegal, cyclic constructor calls
-
+ |
+
+ +
+
this() { a || super(); } // illegal
this() { this(1) || super(); } // ok
@@ -307,7 +356,8 @@
super(); // illegal, inside loop
}
}
-
+ |
+
+
+ A a = new A(3); -+ |
The following steps happen: @@ -348,23 +400,27 @@
+
+ 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 @@
+
+ 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
- }
+ }
+ |
+
+ 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
- }
+ }
+ |
+
+ 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.
+
+ 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);
}
}
-
+ |
+
+ 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 @@
+
+ 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. -
- InterfaceDeclaration:
- interface Identifier InterfaceBody
- interface Identifier : SuperInterfaces InterfaceBody
-
- SuperInterfaces
- Identifier
- Identifier , SuperInterfaces
-
- InterfaceBody:
- { DeclDefs }
-
++ 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 - +
+ + 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: - -
+ + class Identifier : SuperClass InterfaceClasses + ClassBody + + new (ArgumentList) Identifier (ArgumentList); + |
+ + where Identifier is the name generated for the anonymous + nested class.
+ + + + +
@@ -265,6 +265,20 @@
+ + + + +
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 @@
@@ -561,6 +561,20 @@
+ + + + +
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 @@
@@ -591,6 +591,20 @@
+ + + + +
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 @@
@@ -38,7 +38,7 @@
| D
+
+ 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. + +
+
+ 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) );
+ }
+ |
+
+ + + + + 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 @@
@@ -37,7 +37,7 @@
| D
+
+ #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. + +
+
+ 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;
+ }
+ |
+ +
+ + + + +
@@ -262,6 +262,20 @@
+ + + + +
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 @@
@@ -562,6 +562,20 @@
+ + + + +
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 @@
@@ -37,7 +37,7 @@
| D
+ + + + + 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 @@
@@ -39,7 +39,7 @@
| D
+ + + + +
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 @@
@@ -684,6 +684,20 @@
+ + + + +
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 @@
@@ -220,6 +220,20 @@
+ + + + +
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 @@
@@ -328,6 +328,20 @@
+ + + + +
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 @@
@@ -159,6 +159,20 @@
+ + + + +
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 @@
@@ -251,6 +251,20 @@
+ + + + +
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 @@
@@ -37,7 +37,7 @@
| D
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. +
+ + 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: + +
+
+ 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
+ ...
+ }
+ |
+ +
+
+ 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");
+ }
+ |
+ +
+ + 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");
+ }
+ |
+ +
+
+ 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
+ ...
+ }
+ |
+ +
+
+ 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. +
+ +
+ + 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
+}
+ |
+ +
+ + + + + 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 @@
@@ -524,6 +524,20 @@
+ + + + +
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 @@
@@ -191,6 +191,20 @@
+ + + + +
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 @@
@@ -37,7 +37,7 @@
| D
-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:
+
+
- 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; + |
+ +
+ + 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 @@ }
-
+ + 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
+ |
+ +
+ + + + + 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 @@
@@ -61,6 +61,20 @@
+ + + + +
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 @@
@@ -356,6 +356,20 @@
+ + + + +
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 @@
@@ -99,6 +99,20 @@
+ + + + +
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 @@
@@ -508,6 +508,20 @@
+ + + + +
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 @@
@@ -1106,6 +1106,20 @@
+ + + + +
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 @@ - + + - -
@@ -37,368 +37,198 @@
| D
- - 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 - |
- 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: + ... -
-
+
+ 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();
}
- |
-
+ class B : D + { + int foo() { } // error, no void foo() implementation + } +
- 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();
+ }
- |
-
+
+ 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.
- |
- 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 +
-
- 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. - -
- - D class objects are incompatible with C++ class objects. +
+ + + + + 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 @@ - - - - - - - - - - - - - - - - + +
- -
-Home
-| Search
-| D
-
-"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. -
+
+ +"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:- 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 + --
- - 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 @@
@@ -938,6 +938,20 @@
+ + + + +
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 @@
@@ -37,7 +37,7 @@
| D
- 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 @@
+ + + + +
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 @@
@@ -352,6 +352,20 @@
+ + + + +
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 @@
@@ -313,6 +313,20 @@
+ + + + +
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 @@
@@ -600,6 +600,20 @@
+ + + + +
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 @@
@@ -951,6 +951,20 @@
+ + + + +
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 @@
@@ -37,7 +37,7 @@
| D
+ + + + +
@@ -138,6 +138,20 @@
+ + + + +
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 @@
@@ -149,6 +149,20 @@
+ + + + +
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 @@
@@ -737,6 +737,20 @@
+ + + + +
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 @@
@@ -179,6 +179,20 @@
+ + + + +
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 @@
@@ -37,7 +37,7 @@
| D
- 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 @@
+ + + + + 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 @@
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 @@
+
+
+
+
+
+
+
+
+[Home]
+[Search]
+[D]
+
++ +
+ +
+
+
+
+
@@ -153,6 +153,20 @@
+ + + + +
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 @@
@@ -706,6 +706,20 @@
+ + + + +
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 @@ - + + + + --
@@ -300,6 +300,20 @@
+ + + + +
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 @@
@@ -37,7 +37,7 @@
| D
+
+ 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 -+ |
-
+
+ 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 @@
+
+ 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 @@
+
+ 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 @@
+
+ StaticIfCondition: static if ( AssignExpression ) -+ |
AssignExpression is implicitly converted to a boolean type, and is evaluated at compile time. @@ -467,23 +481,46 @@
+
+ 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:
+
+ 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");
+ }
+ |
+ +
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 @@
}
-
alias short bar;
- int foo(bar x)
+ void foo(bar x)
{
iftype (bar T)
alias T S;
@@ -530,7 +571,7 @@
|