diff -uNr dmd-0.128/dmd/html/d/attribute.html dmd-0.129/dmd/html/d/attribute.html --- dmd-0.128/dmd/html/d/attribute.html 2005-05-19 15:08:50.000000000 +0200 +++ dmd-0.129/dmd/html/d/attribute.html 2005-07-23 11:41:02.000000000 +0200 @@ -37,7 +37,7 @@ | D
-Last update Thu May 19 2005 +Last update Sat Jul 23 2005

Attributes

@@ -67,9 +67,9 @@ export static final - override + override abstract - const + const auto AttributeElse: @@ -307,7 +307,7 @@ member. Export is analogous to exporting definitions from a DLL. -

Const Attribute

+

Const Attribute

@@ -329,7 +329,63 @@ }

-

Override Attribute

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

+
+

+	const int x;
+	const int y;
+
+	static this()
+	{
+	    x = 3;	// ok
+	    // error: y not initialized
+	}
+
+	void foo()
+	{
+	    x = 4;	// error, x is const and not in static constructor
+	}
+
+	class C
+	{
+	    const int a;
+	    const int b;
+	    static const int c;
+	    static const int d;
+
+	    this()
+	    {	a = 3;		// ok
+		a = 4;		// ok, multiple initialization allowed
+		C p = this;
+		p.a = 4;	// error, only members of this instance
+		c = 5;		// error, should initialize in static constructor
+		// error, b is not initialized
+	    }
+
+	    this(int x);
+	    {
+		this();		// ok, forwarding constructor
+	    }
+
+	    static this()
+	    {
+		c = 3;		// ok
+		// error, d is not initialized
+	    }
+	}
+	

+ + It is not an error to have const module variable declarations without + initializers if there is no constructor. This is to support the practice + of having modules serve only as declarations that are not linked in, + the implementation of it will be in another module that is linked in. + + +

Override Attribute

diff -uNr dmd-0.128/dmd/html/d/changelog.html dmd-0.129/dmd/html/d/changelog.html --- dmd-0.128/dmd/html/d/changelog.html 2005-07-10 23:32:10.000000000 +0200 +++ dmd-0.129/dmd/html/d/changelog.html 2005-08-06 21:59:06.000000000 +0200 @@ -37,7 +37,7 @@ | D
-Last update Sun Jul 10 2005 +Last update Sat Aug 06 2005
@@ -45,6 +45,7 @@
+

+ What's New for + D 0.129 +

+ +Aug 5, 2005 +

+ +

New/Changed Features

+
    +
  • Added postfixes c, w, d to string literals to denote type. +
  • +
  • For linux, DW_LANG_D is used for DW_AT_language in the Dwarf + symbolic debug info. If the + -gc switch is used, DW_LANG_C is used for older GDB's. +
  • +
  • Incorporated Ben Hinkle's new std.format which can print + general arrays. +
  • +
  • Added std.stdio.writefx and std.stream.writefx + from David L. Davis and Ben Hinkle. +
  • Incorporated Ameer Armaly's improvement to std.c.linux.linux.
  • +
+ +

Bugs Fixed

+
    +
  • Implemented access checking for structs.
  • +
  • Fixed D.bugs/4555
  • +
+ +

What's New for D 0.128 diff -uNr dmd-0.128/dmd/html/d/dcompiler.html dmd-0.129/dmd/html/d/dcompiler.html --- dmd-0.128/dmd/html/d/dcompiler.html 2005-05-19 15:08:50.000000000 +0200 +++ dmd-0.129/dmd/html/d/dcompiler.html 2005-07-30 20:50:54.000000000 +0200 @@ -37,7 +37,7 @@ | D
-Last update Thu May 19 2005 +Last update Sat Jul 30 2005
@@ -414,6 +414,8 @@
compile in debug code identified by ident
-g
add symbolic debug info +
-gc
+
add symbolic debug info in C format (for older gdb's)
-inline
inline expand functions
-Ipath diff -uNr dmd-0.128/dmd/html/d/dlinks.html dmd-0.129/dmd/html/d/dlinks.html --- dmd-0.128/dmd/html/d/dlinks.html 2005-06-07 02:52:40.000000000 +0200 +++ dmd-0.129/dmd/html/d/dlinks.html 2005-08-06 21:59:06.000000000 +0200 @@ -39,7 +39,7 @@ | D
-Last update Tue Jun 07 2005 +Last update Sat Aug 06 2005

D Links

@@ -90,6 +90,10 @@
  • DMD Front End Starter Kit +
  • akIDE + is an open source IDE written in D. Comes with D syntax colouring, D + project wizard and DMD compiler support. +
  • Andy Friesen has taken SWIG and @@ -181,10 +185,6 @@
  • TUMIKI Fighters game implemented in D. - -
  • A small - - sample game.

    Media

    @@ -247,8 +247,6 @@ http://www.scratch-ware.net/D/. -
  • KDE Linux Support for D -
  • AFB's The D Language
  • @@ -280,7 +278,7 @@
  • - The Code Moon + The Code Moon
  • @@ -296,9 +294,13 @@ language shootout D benchmarks.
    + @@ -316,10 +318,6 @@
  • Justin's D Stuff -
  • Joel Anderson's D Page - contains dig modified to support .81 and a GLee port which supports - around 300 openGL extensions. -
  • Stephan Wienczny's D Programming page.
  • MKoD @@ -345,6 +343,9 @@ database independent interface for the D programming language
  • Harmonia + +
  • Unsorted D links +

    Japanese Language

    @@ -366,27 +367,23 @@
  • Windows header files. + -
  • Unsorted D links +
  • + TUMIKI Fighters game implemented in D. diff -uNr dmd-0.128/dmd/html/d/faq.html dmd-0.129/dmd/html/d/faq.html --- dmd-0.128/dmd/html/d/faq.html 2005-05-19 15:08:50.000000000 +0200 +++ dmd-0.129/dmd/html/d/faq.html 2005-07-30 20:52:04.000000000 +0200 @@ -37,7 +37,7 @@ | D
    -Last update Thu May 19 2005 +Last update Sat Jul 30 2005
    @@ -54,7 +54,7 @@
  • Is there linux port of D?
  • Is there a GNU version of D?
  • How do I write my own D compiler for CPU X? -
  • Where can I get a GUI for D? +
  • Where can I get a GUI library for D?
  • Where can I get an IDE for D?
  • What about templates?
  • Why emphasize implementation ease? @@ -67,7 +67,6 @@
  • Can't garbage collection be done in C++ with an add-on library?
  • Can't unit testing be done in C++ with an add-on library?
  • Why have an asm statement in a portable language? -
  • Is there a GUI library for D?
  • What is the point of 80 bit reals?
  • How do I do anonymous struct/unions in D?
  • How do I get printf() to work with strings? @@ -113,12 +112,11 @@
    -

    Where can I get a GUI for D?

    - - DUI is a graphical user - interface based on the - GTK+ graphical toolkit. +

    Where can I get a GUI library for D?

    + Since D can call C functions, any GUI library with a C interface is + accessible from D. Various D GUI libraries and ports can be found at + AvailableGuiLibraries.

    Where can I get an IDE for D?

    @@ -275,13 +273,6 @@ assembler provided reliability and consistency.
    -

    Is there a GUI library for D?

    - - Since D can call C functions, any GUI library with a C interface is - accessible from D. Various D GUI libraries and ports can be found at - AvailableGuiLibraries. - -

    What is the point of 80 bit reals?

    More precision enables more accurate floating point computations diff -uNr dmd-0.128/dmd/html/d/interfaceToC.html dmd-0.129/dmd/html/d/interfaceToC.html --- dmd-0.128/dmd/html/d/interfaceToC.html 1970-01-01 01:00:00.000000000 +0100 +++ dmd-0.129/dmd/html/d/interfaceToC.html 2005-06-06 17:59:00.000000000 +0200 @@ -0,0 +1,430 @@ + + + + + + + + + + + + + + + + + + + + + +D Programming Language - Interfacing to C + + + + +www.digitalmars.com + +Home +| Search +| D + +
    +Last update Mon Jun 06 2005 +
    + + +

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

    Calling C Functions

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

    + + The C function must be declared and given a calling convention, + most likely the "C" calling convention, for example: + +

    +
    +
    
    +	extern (C) int strcmp(char* string1, char* string2);
    +	

    + + and then it can be called within D code in the obvious way: + +

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

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

      +
    • D understands how C function names are "mangled" and the + correct C function call/return sequence. + +
    • C functions cannot be overloaded with another C function + with the same name. + +
    • There are no __cdecl, __far, __stdcall, __declspec, or other + such C type modifiers in D. These are handled by attributes, such + as extern (C). + +
    • 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. + +
    • Strings are not 0 terminated in D. See "Data Type Compatibility" + for more information about this. However, string literals in D are + 0 terminated. +
    + + 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): + +

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

    + +

    Storage Allocation

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

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

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

      + +
    • Making a copy of the data using c.stdlib.malloc() and passing + the copy instead. + +
    • 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. + +
    • Registering the pointer with the garbage collector with the + gc.addRoot() or gc.addRange() calls. + +
    + + 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. +

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

    + + 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()

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

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

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

    + + An improved D function for formatted output is + std.stdio.writef(). + +

    Structs and Unions

    + + D structs and unions are analogous to C's. +

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

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

    Feedback and Comments

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

    + + + + + + + + + + diff -uNr dmd-0.128/dmd/html/d/intro.html dmd-0.129/dmd/html/d/intro.html --- dmd-0.128/dmd/html/d/intro.html 2005-06-18 13:39:00.000000000 +0200 +++ dmd-0.129/dmd/html/d/intro.html 2005-07-30 11:51:48.000000000 +0200 @@ -72,6 +72,8 @@

  • Kazuhiro Inaba has prepared a Japanese translation.
  • +
  • Christian Hartung has prepared a + Portugese translation.
  • "D Language Perfect Guide" diff -uNr dmd-0.128/dmd/html/d/lex.html dmd-0.129/dmd/html/d/lex.html --- dmd-0.128/dmd/html/d/lex.html 2005-05-19 15:08:50.000000000 +0200 +++ dmd-0.129/dmd/html/d/lex.html 2005-07-19 10:11:16.000000000 +0200 @@ -37,7 +37,7 @@ | D
    -Last update Thu May 19 2005 +Last update Tue Jul 19 2005

    Lexical

    @@ -360,17 +360,17 @@ HexString WysiwygString: - r" WysiwygCharacters " + r" WysiwygCharacters " Postfixopt AlternateWysiwygString: - ` WysiwygCharacters ` + ` WysiwygCharacters ` Postfixopt WysiwygCharacter: Character EndOfLine DoubleQuotedString: - " DoubleQuotedCharacters " + " DoubleQuotedCharacters " Postfixopt DoubleQuotedCharacter: Character @@ -399,12 +399,17 @@ \& NamedCharacterEntity ; HexString: - x" HexStringChars " + x" HexStringChars " Postfixopt HexStringChar HexDigit WhiteSpace EndOfLine + + Postfix + c + w + d

    A string literal is either a double quoted string, a wysiwyg quoted @@ -494,6 +499,27 @@ \x61"bc" + The optional Postfix character gives a specific type + to the string, rather than it being inferred from the context. + This is useful when the type cannot be unambiguously inferred, + such as when overloading based on string type. The types corresponding + to the postfix characters are: +

    + + + + + + + + + +
    Postfix + Type +
    c char[ ] +
    w wchar[ ] +
    d dchar[ ] +

    Character Literals

    diff -uNr dmd-0.128/dmd/html/d/phobos.html dmd-0.129/dmd/html/d/phobos.html --- dmd-0.128/dmd/html/d/phobos.html 2005-06-07 21:54:28.000000000 +0200 +++ dmd-0.129/dmd/html/d/phobos.html 2005-08-06 21:59:06.000000000 +0200 @@ -37,7 +37,7 @@ | D
    -Last update Tue Jun 07 2005 +Last update Sat Aug 06 2005
    @@ -1774,6 +1774,13 @@
    Same as writefln, but output is sent to the stream fp instead of stdout.

    + +

    void writefx(FILE* fp, TypeInfo[] arguments, void* argptr, int newline = false); +
    Same as writef, but output is sent to the + stream fp instead of stdout, the variadic inputs + are expanded to the arguments and argptr pair and + the newline is an optional parameter with no newline by default. +


    diff -uNr dmd-0.128/dmd/html/d/std_format.html dmd-0.129/dmd/html/d/std_format.html --- dmd-0.128/dmd/html/d/std_format.html 2005-04-15 14:13:42.000000000 +0200 +++ dmd-0.129/dmd/html/d/std_format.html 2005-08-01 19:16:44.000000000 +0200 @@ -1,7 +1,7 @@ -