4 | pointer to array data
+ offset | contents |
+ 0 | array dimension |
+ 4 | pointer to array data |
@@ -247,7 +239,7 @@
int[3] abc;
- Passing abc to functions results in these implicit conversions:
+ Passing abc to functions results in these implicit conversions:
void func(int[3] array); void func(int* p);
A static destructor is defined as a special static function with the
- syntax static ~this().
+ syntax static ~this()
+.
class Foo
{
@@ -707,7 +715,8 @@
Invariants contain assert expressions, and so when they fail,
- they throw a AssertErrors.
+ they throw a AssertError
+s.
Class invariants are inherited, that is,
any class invariant is implicitly anded with the invariants of its base
classes.
@@ -745,6 +754,7 @@
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.
@@ -792,7 +802,8 @@
set to the size in bytes of the memory to be allocated for the
instance.
The allocator must allocate the memory and return it as a
- void*.
+ void*
+.
If the allocator fails, it must not return a null, but
must throw an exception.
If there is more than one parameter to the allocator, the
@@ -841,7 +852,8 @@
is called a class deallocator.
- The deallocator must have exactly one parameter of type void*.
+ The deallocator must have exactly one parameter of type void*
+.
Only one can be specified for a class.
When a delete expression:
diff -uNr dmd-0.176/dmd/html/d/code_coverage.html dmd-0.177/dmd/html/d/code_coverage.html
--- dmd-0.176/dmd/html/d/code_coverage.html 2006-11-27 18:15:58.000000000 +0100
+++ dmd-0.177/dmd/html/d/code_coverage.html 2006-12-09 00:40:30.000000000 +0100
@@ -31,7 +31,7 @@
- Last update Mon Nov 27 18:15:57 2006
+ Last update Sat Dec 9 00:40:28 2006
@@ -294,7 +294,8 @@
sieve
-The output file will be created called sieve.lst, the contents of
+ The output file will be created called sieve.lst
+, the contents of
which are:
|/* Eratosthenes Sieve prime number calculation. */
@@ -335,11 +336,13 @@
There are 3 lines with an exection count
-of 1, these were each executed once. The declaration line for i, prime,
+of 1, these were each executed once. The declaration line for i, prime
+,
etc., has 5 because there are 5 declarations, and the initialization of
each declaration counts as one statement.
-The first for loop shows 22. This is the sum of the 3 parts
+ The first for
+ loop shows 22. This is the sum of the 3 parts
of the for header. If the for header is broken up into 3 lines, the
data is similarly divided:
@@ -350,8 +353,11 @@
which adds up to 22.
-e1&&e2 and e1||e2 expressions conditionally
-execute the rvalue e2.
+ e1&&e2
+ and e1||e2
+ expressions conditionally
+execute the rvalue e2
+.
Therefore, the rvalue is treated as a separate statement with its own
counter:
@@ -374,8 +380,11 @@
|}
-Similarly, for the e?e1:e2 expressions, e1 and
-e2 are treated as separate statements.
+Similarly, for the e?e1:e2
+ expressions, e1
+ and
+e2
+ are treated as separate statements.
Controlling the Coverage Analyser
diff -uNr dmd-0.176/dmd/html/d/comparison.html dmd-0.177/dmd/html/d/comparison.html
--- dmd-0.176/dmd/html/d/comparison.html 2006-11-27 18:15:56.000000000 +0100
+++ dmd-0.177/dmd/html/d/comparison.html 2006-12-05 18:54:32.000000000 +0100
@@ -31,7 +31,7 @@
- Last update Mon Nov 27 18:15:55 2006
+ Last update Tue Dec 5 18:54:31 2006
@@ -91,7 +91,6 @@
To D, or not to D. -- Willeam NerdSpeare
-
This table is a quick and rough comparison of various features of
D
diff -uNr dmd-0.176/dmd/html/d/cppcomplex.html dmd-0.177/dmd/html/d/cppcomplex.html
--- dmd-0.176/dmd/html/d/cppcomplex.html 2006-11-27 18:15:52.000000000 +0100
+++ dmd-0.177/dmd/html/d/cppcomplex.html 2006-12-05 18:54:30.000000000 +0100
@@ -32,7 +32,7 @@
- Last update Mon Nov 27 18:15:51 2006
+ Last update Tue Dec 5 18:54:28 2006
@@ -229,7 +229,6 @@
Arithmetic; it needs the Imaginary type."
-
The semantic problems are:
diff -uNr dmd-0.176/dmd/html/d/cppdbc.html dmd-0.177/dmd/html/d/cppdbc.html
--- dmd-0.176/dmd/html/d/cppdbc.html 2006-11-27 18:15:54.000000000 +0100
+++ dmd-0.177/dmd/html/d/cppdbc.html 2006-12-09 00:40:28.000000000 +0100
@@ -32,7 +32,7 @@
- Last update Mon Nov 27 18:15:52 2006
+ Last update Sat Dec 9 00:40:27 2006
@@ -145,20 +145,27 @@
Contract Programming in C++
-The assert Macro
+The assert
+ Macro
- C++ does have the basic assert macro, which tests its argument
- and if it fails, aborts the program. assert can be turned
- on and off with the NDEBUG macro.
+ C++ does have the basic assert
+ macro, which tests its argument
+ and if it fails, aborts the program. assert
+ can be turned
+ on and off with the NDEBUG
+ macro.
- assert does not know anything about class invariants,
+ assert
+ does not know anything about class invariants,
and does not throw an exception when it fails. It just aborts
- the program after writing a message. assert relies on
+ the program after writing a message. assert
+ relies on
a macro text preprocessor to work.
- assert is where explicit support for DbC in Standard C++
+ assert
+ is where explicit support for DbC in Standard C++
begins and ends.
Class Invariants
@@ -237,8 +244,10 @@
}
- There's an additional complication with A::foo(). Upon every
- normal exit from the function, the invariant() should be
+ There's an additional complication with A::foo()
+. Upon every
+ normal exit from the function, the invariant()
+ should be
called.
This means that code that looks like:
@@ -317,14 +326,19 @@
If the preconditions and postconditions consist of nothing
- more than assert macros, the whole doesn't need to
- be wrapped in a #ifdef pair, since a good C++ compiler will
- optimize the whole thing away if the asserts are turned off.
+ more than assert
+ macros, the whole doesn't need to
+ be wrapped in a #ifdef
+ pair, since a good C++ compiler will
+ optimize the whole thing away if the assert
+s are turned off.
- But suppose foo() sorts an array, and the postcondition needs
+ But suppose foo()
+ sorts an array, and the postcondition needs
to walk the array and verify that it really is sorted. Now
- the shebang needs to be wrapped in #ifdef:
+ the shebang needs to be wrapped in #ifdef
+:
void foo()
{
@@ -339,12 +353,15 @@
(One can make use of the C++ rule that templates are only
- instantiated when used can be used to avoid the #ifdef, by
+ instantiated when used can be used to avoid the #ifdef
+, by
putting the conditions into a template function referenced
- by the assert.)
+ by the assert
+.)
- Let's add a return value to foo() that needs to be checked in
+ Let's add a return value to foo()
+ that needs to be checked in
the postconditions. In D:
int foo()
@@ -385,7 +402,8 @@
}
- Now add a couple parameters to foo(). In D:
+ Now add a couple parameters to foo()
+. In D:
int foo(int a, int b)
in { ...preconditions... }
@@ -458,7 +476,8 @@
}
- The semantics for a call to B.foo() are:
+ The semantics for a call to B.foo()
+ are:
- Either Apreconditions or Bpreconditions must be satisfied.
@@ -520,16 +539,20 @@
Something interesting has happened here. The preconditions can
- no longer be done using assert, since the results need
+ no longer be done using assert
+, since the results need
to be OR'd together. I'll leave as a reader exercise adding
- in a class invariant, function return values for foo(),
+ in a class invariant, function return values for foo()
+,
and parameters
- for foo().
+ for foo()
+.
Conclusion
These C++ techniques can work up to a point. But, aside from
- assert, they are not standardized and so will vary from
+ assert
+, they are not standardized and so will vary from
project to project. Furthermore, they require much tedious
adhesion to a particular convention, and add significant clutter
to the code. Perhaps that's why it's rarely seen in practice.
diff -uNr dmd-0.176/dmd/html/d/cppstrings.html dmd-0.177/dmd/html/d/cppstrings.html
--- dmd-0.176/dmd/html/d/cppstrings.html 2006-11-27 18:15:52.000000000 +0100
+++ dmd-0.177/dmd/html/d/cppstrings.html 2006-12-09 00:40:28.000000000 +0100
@@ -33,7 +33,7 @@
- Last update Mon Nov 27 18:15:51 2006
+ Last update Sat Dec 9 00:40:26 2006
@@ -243,9 +243,12 @@
char[] s1;
foo(s1);
- although for this to work where foo expects a 0 terminated
- string, s1 must have a terminating 0. Alternatively, the
- function std.string.toStringz will ensure it:
+ although for this to work where foo
+ expects a 0 terminated
+ string, s1
+ must have a terminating 0. Alternatively, the
+ function std.string.toStringz
+ will ensure it:
void foo(char*);
char[] s1;
diff -uNr dmd-0.176/dmd/html/d/cpptod.html dmd-0.177/dmd/html/d/cpptod.html
--- dmd-0.176/dmd/html/d/cpptod.html 2006-11-27 18:15:52.000000000 +0100
+++ dmd-0.177/dmd/html/d/cpptod.html 2006-12-09 00:40:28.000000000 +0100
@@ -32,7 +32,7 @@
- Last update Mon Nov 27 18:15:51 2006
+ Last update Sat Dec 9 00:40:26 2006
@@ -331,7 +331,8 @@
Sometimes two classes are tightly related but not by inheritance,
but need to access each other's private members. This is done
- using friend declarations:
+ using friend
+ declarations:
class A
{
@@ -390,7 +391,8 @@
int abc(A p) { return p.a; }
- The private attribute prevents other modules from
+ The private
+ attribute prevents other modules from
accessing the members.
@@ -431,7 +433,8 @@
The compiler automatically interprets all the
<, <=, > and >=
- operators in terms of the cmp function, as well
+ operators in terms of the cmp
+ function, as well
as handling the cases where the left operand is not an
object reference.
@@ -500,6 +503,7 @@
of and freeing memory. This is handled automatically in D by
the garbage collector. The second common resources used are semaphores
and locks, handled automatically with D's synchronized
+
declarations and statements.
diff -uNr dmd-0.176/dmd/html/d/ctod.html dmd-0.177/dmd/html/d/ctod.html
--- dmd-0.176/dmd/html/d/ctod.html 2006-11-27 18:15:52.000000000 +0100
+++ dmd-0.177/dmd/html/d/ctod.html 2006-12-09 00:40:28.000000000 +0100
@@ -33,7 +33,7 @@
- Last update Mon Nov 27 18:15:51 2006
+ Last update Sat Dec 9 00:40:26 2006
@@ -93,67 +93,62 @@
Et tu, D? Then fall, C! -- William Nerdspeare
-
-Every experienced C programmer accumulates a series of idioms and techniques
+Every experienced C programmer accumulates a series of idioms and techniques
which become second nature. Sometimes, when learning a new language, those
idioms can be so comfortable it's hard to see how to do the equivalent in the
new language. So here's a collection of common C techniques, and how to do the
corresponding task in D.
-
+
-Since C does not have object-oriented features, there's a separate section
+Since C does not have object-oriented features, there's a separate section
for object-oriented issues
Programming in D for C++ Programmers.
-
+
-The C preprocessor is covered in
+The C preprocessor is covered in
The C Preprocessor vs D.
+
-
- - Getting the Size of a Type
-
- Get the max and min values of a type
-
- Primitive Types
-
- Special Floating Point Values
-
- Remainder after division of floating point numbers
-
- Dealing with NANs in floating point compares
-
- Asserts
-
- Initializing all elements of an array
-
- Looping through an array
-
- Creating an array of variable size
-
- String Concatenation
-
- Formatted printing
-
- Forward referencing functions
-
- Functions that have no arguments
-
- Labelled break and continue statements
-
- Goto Statements
-
- Struct tag name space
-
- Looking up strings
-
- Setting struct member alignment
-
- Anonymous Structs and Unions
-
- Declaring struct types and variables
-
- Getting the offset of a struct member
-
- Union initializations
-
- Struct initializations
-
- Array initializations
-
- Escaped String Literals
-
- Ascii vs Wide Characters
-
- Arrays that parallel an enum
-
- Creating a new type with typedef
-
- Comparing structs
-
- Comparing strings
-
- Sorting arrays
-
- Volatile memory access
-
- String literals
-
- Data Structure Traversal
-
- Unsigned Right Shift
-
- Dynamic Closures
-
- Variadic Function Parameters
-
-
+
@@ -714,7 +709,8 @@
It's done through a command line switch which affects the entire
program, and woe results if any modules or libraries didn't get
- recompiled. To address this, #pragmas are used:
+ recompiled. To address this, #pragma
+s are used:
#pragma pack(1)
struct ABC
@@ -810,12 +806,12 @@
The C Way
- Is to do it in one statement ending with a semicolon:
+ Is to do it in one statement ending with a semicolon:
struct Foo { int x; int y; } foo;
- Or to separate the two:
+ Or to separate the two:
struct Foo { int x; int y; }; // note terminating ;
struct Foo foo;
@@ -823,15 +819,18 @@
The D Way
- Struct definitions and declarations can't be done in the same statement:
+ Struct definitions and declarations can't be done in the same
+ statement:
+
struct Foo { int x; int y; } Foo foo;
- which means that the terminating ; can be dispensed with, eliminating the
- confusing difference between struct {} and function & block {} in how semicolons
- are used.
+ which means that the terminating ; can be dispensed with,
+ eliminating the confusing difference between struct {} and function
+ block {} in how semicolons are used.
+
@@ -884,7 +883,7 @@
The C Way
- Members are initialized by their position within the {}'s:
+ Members are initialized by their position within the { }s:
struct S { int a; int b; };
struct S x = { 5, 3 };
@@ -1075,7 +1074,8 @@
There are 4 names to remember: Handle, HANDLE_INIT,
- struct Handle__, value.
+ struct Handle__, value
+.
The D Way
@@ -1091,7 +1091,8 @@
To handle a default value, add an initializer to the typedef,
- and refer to it with the .init property:
+ and refer to it with the .init
+ property:
typedef void* Handle = cast(void*)(-1);
Handle h;
@@ -1100,7 +1101,8 @@
...
- There's only one name to remember: Handle.
+ There's only one name to remember: Handle
+.
@@ -1285,9 +1287,11 @@
To make this work, a helper function membersearchx
+
is needed to recursively
walk the trees. The helper function needs to read and write
some context outside of the trees, so a custom struct Paramblock
+
is created and a pointer to it is used to maximize efficiency.
struct Symbol
@@ -1397,7 +1401,10 @@
j = (unsigned)i >> 3;
- If i is an int, this works fine. But if i is
+ If i
+ is an int
+, this works fine. But if i
+ is
of a type created with typedef,
myint i, j;
@@ -1405,7 +1412,9 @@
j = (unsigned)i >> 3;
- and myint happens to be a long int, then the cast to
+ and myint
+ happens to be a long int
+, then the cast to
unsigned
will silently throw away the most significant bits, corrupting
the answer.
@@ -1439,7 +1448,8 @@
A generic context pointer is also needed, represented here by
- void *p. The example here is of a trivial container
+ void *p
+. The example here is of a trivial container
class that holds an array of ints, and a user of that container
that computes the maximum of those ints.
@@ -1555,7 +1565,8 @@
There are two problems with this. The first is that the
- sum function needs to know how many arguments were
+ 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.
diff -uNr dmd-0.176/dmd/html/d/dbc.html dmd-0.177/dmd/html/d/dbc.html
--- dmd-0.176/dmd/html/d/dbc.html 2006-11-27 18:15:56.000000000 +0100
+++ dmd-0.177/dmd/html/d/dbc.html 2006-12-09 00:40:28.000000000 +0100
@@ -32,7 +32,7 @@
- Last update Mon Nov 27 18:15:54 2006
+ Last update Sat Dec 9 00:40:27 2006
@@ -267,65 +267,42 @@
In, Out and Inheritance
- If a function in a derived class overrides a function in its
+ If a function in a derived class overrides a function in its
super class, then only one of
- the in contracts of the function and its base functions
+ the in
+ contracts of the function and its base functions
must be satisfied.
Overriding
functions then becomes a process of loosening the in
+
contracts.
-
+
- A function without an in contract means that any values
+ A function without an in
+ contract means that any values
of the function parameters are allowed. This implies that if any
- function in an inheritance heirarchy has no in contract,
- then in contracts on functions overriding it have no useful
+ function in an inheritance heirarchy has no in
+ contract,
+ then in
+ contracts on functions overriding it have no useful
effect.
-
+
- Conversely, all of the out contracts needs to be satisified, so
- overriding functions becomes a processes of tightening the out
- contracts.
+ Conversely, all of the out
+ contracts needs to be satisfied,
+ so overriding functions becomes a processes of tightening the
+ out
-
+ contracts.
+
Class Invariants
- Class invariants are used to specify characteristics of a class that always
+ Class invariants are used to specify characteristics of a class that
+ always
must be true (except while executing a member function).
They are described in Classes.
-
+
References
diff -uNr dmd-0.176/dmd/html/d/dcompiler.html dmd-0.177/dmd/html/d/dcompiler.html
--- dmd-0.176/dmd/html/d/dcompiler.html 2006-11-27 18:15:56.000000000 +0100
+++ dmd-0.177/dmd/html/d/dcompiler.html 2006-12-09 00:40:30.000000000 +0100
@@ -32,7 +32,7 @@
- Last update Mon Nov 27 18:15:55 2006
+ Last update Sat Dec 9 00:40:28 2006
@@ -203,15 +203,19 @@
- \dmd\src\phobos\
+
- D runtime library source
- \dmd\src\dmd\
+
- D compiler front end source under dual (GPL and Artistic) license
- \dmd\html\d\
+
- Documentation
- \dmd\samples\d\
+
- Sample D programs
@@ -224,15 +228,19 @@
- \dmd\bin\dmd.exe
+
- D compiler executable
- \dmd\bin\shell.exe
+
- Simple command line shell
- \dmd\bin\sc.ini
+
- Global compiler settings
- \dmd\lib\phobos.lib
+
- D runtime library
@@ -260,10 +268,14 @@
they are run from a console window.
Switch to the root directory.
Unzip the files in the root directory.
- dmd.zip will create
- a \dmd directory with all the files in it.
- dmc.zip will create
- a \dm directory with all the files in it.
+ dmd.zip
+ will create
+ a \dmd
+ directory with all the files in it.
+ dmc.zip
+ will create
+ a \dm
+ directory with all the files in it.
A typical session might look like:
@@ -280,7 +292,8 @@
\dmd\bin\shell all.sh
- in the \dmd\samples\d directory for several small examples.
+ in the \dmd\samples\d
+ directory for several small examples.
Compiler Arguments and Switches
@@ -366,6 +379,7 @@
pass linkerflag to the linker, for example,
/ma/li
+
-nofloat
Prevents emission of __fltused reference in
object files, even if floating point code is present.
@@ -483,7 +497,8 @@
conflicting use of environment variables.
- Environment variables follow the [Environment] section
+ Environment variables follow the [Environment]
+ section
heading, in NAME=value pairs.
The NAMEs are treated as upper case.
Comments are lines that start with ;.
@@ -520,19 +535,26 @@
- /dmd/bin/dmd
+
- D compiler executable
- /dmd/bin/dumpobj
+
- Elf file dumper
- /dmd/bin/obj2asm
+
- Elf file disassembler
- /dmd/bin/dmd.conf
-
- Global compiler settings (copy to /etc/dmd.conf)
+
+
- Global compiler settings (copy to /etc/dmd.conf
+)
- /dmd/lib/libphobos.a
-
- D runtime library (copy to /usr/lib/libphobos.a)
+
+
- D runtime library (copy to /usr/lib/libphobos.a
+)
@@ -555,14 +577,18 @@
Unzip the archive into your home directory.
It will create
- a ~/dmd directory with all the files in it.
+ a ~/dmd
+ directory with all the files in it.
All the tools are command line tools, which means
they are run from a console window.
- Edit the file ~/dmd/bin/dmd.conf to put the path in to
+ Edit the file ~/dmd/bin/dmd.conf
+ to put the path in to
where the phobos source files are.
- Copy dmd.conf to /etc:
+ Copy dmd.conf
+ to /etc
+:
cp dmd/bin/dmd.conf /etc
@@ -572,11 +598,14 @@
chmod u+x dmd/bin/dmd dmd/bin/obj2asm dmd/bin/dumpobj
- Put dmd/bin on your PATH,
+ Put dmd/bin
+ on your PATH,
or copy the linux executables
to /usr/local/bin
- Copy the library to /usr/lib:
+
+ Copy the library to /usr/lib
+:
cp dmd/lib/libphobos.a /usr/lib
@@ -661,6 +690,7 @@
-Llinkerflag
pass linkerflag to the linker, for example,
-M
+
-O
optimize
-o-
@@ -747,7 +777,8 @@
conflicting use of environment variables.
- Environment variables follow the [Environment] section
+ Environment variables follow the [Environment]
+ section
heading, in NAME=value pairs.
The NAMEs are treated as upper case.
Comments are lines that start with ;.
@@ -769,6 +800,7 @@
will cause a segment violation.
The configuration file is /etc/dmd.conf
+
diff -uNr dmd-0.176/dmd/html/d/ddoc.html dmd-0.177/dmd/html/d/ddoc.html
--- dmd-0.176/dmd/html/d/ddoc.html 2006-11-27 18:15:58.000000000 +0100
+++ dmd-0.177/dmd/html/d/ddoc.html 2006-12-09 00:40:30.000000000 +0100
@@ -31,7 +31,7 @@
- Last update Mon Nov 27 18:15:56 2006
+ Last update Sat Dec 9 00:40:28 2006
@@ -270,6 +270,7 @@
If a documentation comment for a declaration consists only of the
identifier ditto
+
then the documentation comment for the previous declaration at the same
declaration scope is applied to this declaration as well.
diff -uNr dmd-0.176/dmd/html/d/declaration.html dmd-0.177/dmd/html/d/declaration.html
--- dmd-0.176/dmd/html/d/declaration.html 2006-11-27 18:15:54.000000000 +0100
+++ dmd-0.177/dmd/html/d/declaration.html 2006-12-05 18:54:30.000000000 +0100
@@ -32,7 +32,7 @@
- Last update Mon Nov 27 18:15:52 2006
+ Last update Tue Dec 5 18:54:29 2006
diff -uNr dmd-0.176/dmd/html/d/dlinks.html dmd-0.177/dmd/html/d/dlinks.html
--- dmd-0.176/dmd/html/d/dlinks.html 2006-11-27 18:15:52.000000000 +0100
+++ dmd-0.177/dmd/html/d/dlinks.html 2006-12-05 18:54:30.000000000 +0100
@@ -31,7 +31,7 @@
- Last update Mon Nov 27 18:15:51 2006
+ Last update Tue Dec 5 18:54:28 2006
diff -uNr dmd-0.176/dmd/html/d/dll.html dmd-0.177/dmd/html/d/dll.html
--- dmd-0.176/dmd/html/d/dll.html 2006-11-27 18:15:56.000000000 +0100
+++ dmd-0.177/dmd/html/d/dll.html 2006-12-09 00:40:28.000000000 +0100
@@ -31,7 +31,7 @@
- Last update Mon Nov 27 18:15:54 2006
+ Last update Sat Dec 9 00:40:27 2006
@@ -218,6 +218,7 @@
DLLs can be created in D in roughly the same way as in C.
A DllMain()
+
is required, looking like:
import std.c.windows.windows;
@@ -261,7 +262,8 @@
Notes:
- The _moduleUnitTests() call is optional.
-
- The presence of DllMain() is recognized by the compiler
+
- The presence of DllMain()
+ is recognized by the compiler
causing it to emit a reference to
__acrtused_dll
and the phobos.lib runtime library.
@@ -544,7 +546,8 @@
- DllMain
- This is the main entry point for any D DLL. It gets called
by the C startup code
- (for DMC++, the source is \dm\src\win32\dllstart.c).
+ (for DMC++, the source is \dm\src\win32\dllstart.c
+).
The printf's are placed there so one can trace how it gets
called.
Notice that the initialization and termination code seen in
@@ -613,20 +616,46 @@
- To build the mydll.dll DLL:
+ To build the mydll.dll
+ DLL:
- - dmd -c mydll -g
-
Compiles mydll.d into mydll.obj.
+ - dmd -c mydll -g
+
+
Compiles mydll.d
+ into mydll.obj
+.
-g turns on debug info generation.
- - dmd mydll.obj \dmd\lib\gcstub.obj mydll.def -g -L/map
-
Links mydll.obj into a DLL named mydll.dll.
- gcstub.obj is not required, but it prevents the bulk
+ - dmd mydll.obj \dmd\lib\gcstub.obj mydll.def -g -L/map
+
+
Links mydll.obj
+ into a DLL named
+
+
+
+
+
+
+
+
+
+mydll.dll).
+ gcstub.obj
+ is not required, but it prevents the bulk
of the gc code from being linked in, since it will not be used
anyway. It saves about 12Kb.
- mydll.def is the
+ mydll.def
+ is the
Module Definition File,
and has the contents:
@@ -638,21 +667,27 @@
-g turns on debug info generation, and
- -L/map generates a map file mydll.map.
+ -L/map generates a map file mydll.map
+.
- - implib /noi /system mydll.lib mydll.dll
+
- implib /noi /system mydll.lib mydll.dll
+
Creates an
import library
- mydll.lib suitable
+ mydll.lib
+ suitable
for linking in with an application that will be statically
- loading mydll.dll.
+ loading mydll.dll
+.
- Here's test.d, a sample application that makes use of
- mydll.dll. There are two versions, one statically binds to
+ Here's test.d
+, a sample application that makes use of
+ mydll.dll
+. There are two versions, one statically binds to
the DLL, and the other dynamically loads it.
import std.stdio;
@@ -755,14 +790,21 @@
C:>dmd test mydll.lib -g
- Note how it is linked with mydll.lib, the import library
- for mydll.dll.
- The code is straightforward, it initializes mydll.lib with
+ Note how it is linked with mydll.lib
+, the import library
+ for mydll.dll
+.
+ The code is straightforward, it initializes mydll.lib
+ with
a call to MyDLL_Initialize(), passing the handle
- to test.exe's gc.
+ to test.exe
+'s gc.
Then, we can use the DLL and call its functions just as if
- it were part of test.exe. In foo(), gc memory
- is allocated and freed both by test.exe and mydll.dll.
+ it were part of test.exe
+. In foo(), gc memory
+ is allocated and freed both by test.exe
+ and mydll.dll
+.
When we're done using the DLL, it is terminated with
MyDLL_Terminate().
@@ -786,17 +828,20 @@
C:>dmd test -version=DYNAMIC_LOAD -g
- The import library mydll.lib is not needed.
+ The import library mydll.lib
+ is not needed.
The DLL is loaded with a call to
LoadLibraryA(),
and each exported function has to be retrieved via
a call to
GetProcAddress().
An easy way to get the decorated name to pass to GetProcAddress()
- is to copy and paste it from the generated mydll.map file
+ is to copy and paste it from the generated mydll.map
+ file
under the Export heading.
Once this is done, we can use the member functions of the
- DLL classes as if they were part of test.exe.
+ DLL classes as if they were part of test.exe
+.
When done, release the DLL with
FreeLibrary().
@@ -815,25 +860,7 @@
C:>
-
-
-
-
-
-
-
-
-
-
-
+)
diff -uNr dmd-0.176/dmd/html/d/download.html dmd-0.177/dmd/html/d/download.html
--- dmd-0.176/dmd/html/d/download.html 2006-11-27 18:15:58.000000000 +0100
+++ dmd-0.177/dmd/html/d/download.html 2006-12-05 18:54:34.000000000 +0100
@@ -32,7 +32,7 @@
- Last update Mon Nov 27 18:15:57 2006
+ Last update Tue Dec 5 18:54:32 2006
diff -uNr dmd-0.176/dmd/html/d/dstyle.html dmd-0.177/dmd/html/d/dstyle.html
--- dmd-0.176/dmd/html/d/dstyle.html 2006-11-27 18:15:56.000000000 +0100
+++ dmd-0.177/dmd/html/d/dstyle.html 2006-12-05 18:54:32.000000000 +0100
@@ -32,7 +32,7 @@
- Last update Mon Nov 27 18:15:55 2006
+ Last update Tue Dec 5 18:54:30 2006
diff -uNr dmd-0.176/dmd/html/d/entity.html dmd-0.177/dmd/html/d/entity.html
--- dmd-0.176/dmd/html/d/entity.html 2006-11-27 18:15:56.000000000 +0100
+++ dmd-0.177/dmd/html/d/entity.html 2006-12-05 18:54:32.000000000 +0100
@@ -32,7 +32,7 @@
- Last update Mon Nov 27 18:15:54 2006
+ Last update Tue Dec 5 18:54:30 2006
diff -uNr dmd-0.176/dmd/html/d/enum.html dmd-0.177/dmd/html/d/enum.html
--- dmd-0.176/dmd/html/d/enum.html 2006-11-27 18:15:54.000000000 +0100
+++ dmd-0.177/dmd/html/d/enum.html 2006-12-05 18:54:30.000000000 +0100
@@ -32,7 +32,7 @@
- Last update Mon Nov 27 18:15:53 2006
+ Last update Tue Dec 5 18:54:29 2006
diff -uNr dmd-0.176/dmd/html/d/errors.html dmd-0.177/dmd/html/d/errors.html
--- dmd-0.176/dmd/html/d/errors.html 2006-11-27 18:15:56.000000000 +0100
+++ dmd-0.177/dmd/html/d/errors.html 2006-12-05 18:54:32.000000000 +0100
@@ -32,7 +32,7 @@
- Last update Mon Nov 27 18:15:54 2006
+ Last update Tue Dec 5 18:54:30 2006
@@ -134,7 +134,6 @@
I came, I coded, I crashed. -- Julius C'ster
-
All programs have to deal with errors. Errors are unexpected conditions that
are not part of the normal operation of a program. Examples of common errors
are:
diff -uNr dmd-0.176/dmd/html/d/exception-safe.html dmd-0.177/dmd/html/d/exception-safe.html
--- dmd-0.176/dmd/html/d/exception-safe.html 2006-11-27 18:15:58.000000000 +0100
+++ dmd-0.177/dmd/html/d/exception-safe.html 2006-12-09 00:40:30.000000000 +0100
@@ -32,7 +32,7 @@
- Last update Mon Nov 27 18:15:57 2006
+ Last update Sat Dec 9 00:40:28 2006
@@ -432,9 +432,11 @@
Example
The next example involves temporarily changing the state of some object.
-Suppose there's a class data member verbose, which controls the
+Suppose there's a class data member verbose
+, which controls the
emission of messages logging the activity of the class.
-Inside one of the methods, verbose needs to be turned off because
+Inside one of the methods, verbose
+ needs to be turned off because
there's a loop that would otherwise cause a blizzard of messages to be output:
class Foo
@@ -451,7 +453,8 @@
}
-There's a problem if Foo.bar() exits via an exception - the verbose
+There's a problem if Foo.bar()
+ exits via an exception - the verbose
flag state is not restored.
That's easily fixed with scope(exit):
@@ -470,7 +473,8 @@
}
-It also neatly solves the problem if ...lots of code... goes on at
+ It also neatly solves the problem if ...lots of code...
+ goes on at
some length, and in the future a maintenance programmer inserts a
return statement in it, not realizing that verbose must be reset upon
exit. The reset code is where it belongs conceptually, rather than where
diff -uNr dmd-0.176/dmd/html/d/expression.html dmd-0.177/dmd/html/d/expression.html
--- dmd-0.176/dmd/html/d/expression.html 2006-12-02 02:29:14.000000000 +0100
+++ dmd-0.177/dmd/html/d/expression.html 2006-12-09 00:40:28.000000000 +0100
@@ -31,7 +31,7 @@
- Last update Sat Dec 2 02:29:13 2006
+ Last update Sat Dec 9 00:40:27 2006
@@ -137,11 +137,11 @@
These values can then be assigned,
tested, or ignored. Expressions can also have side effects.
-StringLiterals:
+StringLiterals:
StringLiteral
StringLiterals StringLiteral
-ArgumentList:
+ArgumentList:
AssignExpression
AssignExpression , ArgumentList
@@ -163,7 +163,7 @@
-Expression:
+Expression:
AssignExpression
AssignExpression , Expression
@@ -175,7 +175,7 @@
Assign Expressions
-AssignExpression:
+AssignExpression:
ConditionalExpression
ConditionalExpression = AssignExpression
ConditionalExpression += AssignExpression
@@ -216,7 +216,7 @@
Conditional Expressions
-ConditionalExpression:
+ConditionalExpression:
OrOrExpression
OrOrExpression ? Expression : ConditionalExpression
@@ -233,7 +233,7 @@
OrOr Expressions
-OrOrExpression:
+OrOrExpression:
AndAndExpression
OrOrExpression || AndAndExpression
@@ -259,7 +259,7 @@
AndAnd Expressions
-AndAndExpression:
+AndAndExpression:
OrExpression
AndAndExpression && OrExpression
@@ -295,7 +295,7 @@
Or Expressions
-OrExpression:
+OrExpression:
XorExpression
OrExpression | XorExpression
@@ -304,7 +304,7 @@
Xor Expressions
-XorExpression:
+XorExpression:
AndExpression
XorExpression ^ AndExpression
@@ -313,7 +313,7 @@
And Expressions
-AndExpression:
+AndExpression:
EqualExpression
AndExpression & EqualExpression
@@ -323,7 +323,7 @@
-EqualExpression:
+EqualExpression:
RelExpression
EqualExpression == RelExpression
EqualExpression != RelExpression
@@ -363,9 +363,13 @@
For class and struct objects, the expression (a == b)
+
is rewritten as
- a.opEquals(b), and (a != b) is rewritten as
- !a.opEquals(b).
+ a.opEquals(b)
+, and (a != b)
+ is rewritten as
+ !a.opEquals(b)
+.
For static and dynamic arrays, equality is defined as the
@@ -380,7 +384,8 @@
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.
@@ -403,7 +408,7 @@
Relational Expressions
-RelExpression:
+RelExpression:
ShiftExpression
InExpression
RelExpression < ShiftExpression
@@ -448,8 +453,7 @@
types.
-
- Integer comparison operators
+ Integer comparison operators
Operator | Relation |
@@ -466,11 +470,11 @@
!= | not equal |
-
- It is an error to have one operand be signed and the other
+ It is an error to have one operand be signed and the other
unsigned for a <, <=, > or >= expression.
Use casts to make both operands signed or both operands unsigned.
+
@@ -487,8 +491,7 @@
conditions to test for:
-
- Floating point comparison operators
+ Floating point comparison operators
Operator
| Greater Than
@@ -543,18 +546,20 @@
|
Notes:
-
- - For floating point comparison operators, (a !op b) is not the same as !(a op b).
-
- "Unordered" means one or both of the operands is a NAN.
-
- "Exception" means the Invalid Exception is raised if one
+
+
- For floating point comparison operators, (a !op b) is not the same
+ as !(a op b).
+ - "Unordered" means one or both of the operands is a NAN.
+ - "Exception" means the Invalid Exception is raised if one
of the operands is a NAN. It does not mean an exception
is thrown. The Invalid Exception can be checked
using the functions in std.c.fenv.
+
In Expressions
-InExpression:
+InExpression:
RelExpression in ShiftExpression
@@ -575,7 +580,7 @@
Shift Expressions
-ShiftExpression:
+ShiftExpression:
AddExpression
ShiftExpression << AddExpression
ShiftExpression >> AddExpression
@@ -602,7 +607,7 @@
Add Expressions
-AddExpression:
+AddExpression:
MulExpression
AddExpression + MulExpression
AddExpression - MulExpression
@@ -637,7 +642,7 @@
Cat Expressions
-CatExpression:
+CatExpression:
AddExpression ~ MulExpression
@@ -651,7 +656,7 @@
Mul Expressions
-MulExpression:
+MulExpression:
UnaryExpression
MulExpression * UnaryExpression
MulExpression / UnaryExpression
@@ -706,18 +711,18 @@
New Expressions
-NewExpression:
+NewExpression:
NewArguments Type [ AssignExpression ]
NewArguments Type ( ArgumentList )
NewArguments Type
NewArguments ClassArguments BaseClasslistopt { DeclDefs }
-NewArguments:
+NewArguments:
new ( ArgumentList )
new ( )
new
-ClassArguments:
+ClassArguments:
class ( ArgumentList )
class ( )
class
@@ -776,7 +781,7 @@
Delete Expressions
-DeleteExpression:
+DeleteExpression:
delete UnaryExpression
If the UnaryExpression is a class object reference, and
@@ -815,22 +820,24 @@
Cast Expressions
-CastExpression:
+CastExpression:
cast ( Type ) UnaryExpression
- A CastExpression converts the UnaryExpression
+ A CastExpression converts the UnaryExpression
to Type.
+
cast(foo) -p; (foo) - p;
- Any casting of a class reference to a
+ Any casting of a class reference to a
derived class reference is done with a runtime check to make sure it
really is a downcast. null is the result if it isn't.
Note: This is equivalent to the behavior of the
dynamic_cast operator in C++.
+
class A { ... }
class B : A { ... }
@@ -844,8 +851,11 @@
}
- In order to determine if an object o is an instance of
- a class B use a cast:
+ In order to determine if an object o
+ is an instance of
+ a class B
+ use a cast:
+
if (cast(B) o)
{
@@ -857,9 +867,10 @@
}
- Casting a floating point literal from one type to another
+ Casting a floating point literal from one type to another
changes its type, but internally it is retained at full
precision for the purposes of constant folding.
+
void test()
{
@@ -877,9 +888,16 @@
}
+ Casting a value v to a struct S, when value is not a struct
+ of the same type, is equivalent to:
+
+
+S(v)
+
+
Postfix Expressions
-PostfixExpression:
+PostfixExpression:
PrimaryExpression
PostfixExpression . Identifier
PostfixExpression . NewExpression
@@ -893,7 +911,7 @@
Index Expressions
-IndexExpression:
+IndexExpression:
PostfixExpression [ ArgumentList ]
@@ -921,7 +939,7 @@
Slice Expressions
-SliceExpression:
+SliceExpression:
PostfixExpression [ ]
PostfixExpression [ AssignExpression .. AssignExpression ]
@@ -962,7 +980,7 @@
Primary Expressions
-PrimaryExpression:
+PrimaryExpression:
Identifier
.Identifier
this
@@ -1022,7 +1040,8 @@
Within a non-static member function, super resolves to
a reference to the object that called the function, cast to
its base class. It is an error if there is no base class.
- (Only class Object has no base class.)
+ (Only class Object
+ has no base class.)
super is not allowed in struct member
functions.
If a member function is called with an explicit reference
@@ -1059,7 +1078,7 @@
Array Literals
-ArrayLiteral:
+ArrayLiteral:
[ ArgumentList ]
@@ -1083,7 +1102,7 @@
Function Literals
-FunctionLiteral
+FunctionLiteral
function Typeopt ( ArgumentList )opt FunctionBody
delegate Typeopt ( ArgumentList )opt FunctionBody
( ArgumentList ) FunctionBody
@@ -1193,7 +1212,7 @@
Assert Expressions
-AssertExpression:
+AssertExpression:
assert ( Expression )
assert ( Expression , Expression )
@@ -1204,13 +1223,15 @@
It is an error if the expression contains any side effects
that the program depends on. The compiler may optionally not
evaluate assert expressions at all.
- The result type of an assert expression is void.
+ The result type of an assert expression is void
+.
Asserts are a fundamental part of the
Contract Programming
support in D.
- The expression assert(0) is a special case; it
+ The expression assert(0)
+ is a special case; it
signifies that it is unreachable code.
Either AssertError is thrown at runtime if it is reachable,
or the execution is halted
@@ -1221,7 +1242,8 @@
The second Expression, if present, must be implicitly
- convertible to type char[]. It is evaluated if the
+ convertible to type char[]
+. It is evaluated if the
result is false, and the string result is appended to the
AssertError's message.
@@ -1298,7 +1320,6 @@
The forms of the IsExpression are:
-
- is ( Type )
The condition is satisfied if Type is semantically
correct (it must be syntactically correct regardless).
@@ -1439,40 +1460,39 @@
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
+ | typedef |
+ the type that Type is a typedef of |
- struct
- | Type
+ | struct |
+ Type |
- union
- | Type
+ | union |
+ Type |
- class
- | Type
+ | class |
+ Type |
- interface
- | Type
+ | interface |
+ Type |
- super
- | TypeTuple of base classes and interfaces
+ | super |
+ TypeTuple of base classes and interfaces |
- enum
- | the base type of the enum
+ | enum |
+ the base type of the enum |
- function
- | TypeTuple of the function parameter types
+ | function |
+ TypeTuple of the function parameter types |
- delegate
- | the function type of the delegate
+ | delegate |
+ the function type of the delegate |
- return
- | the return type of the function, delegate, or function pointer
+ | return |
+ the return type of the function, delegate, or function pointer |
alias short bar;
@@ -1484,7 +1504,7 @@
alias T U;
static if ( is(E V == enum) ) V v; V v; }
diff -uNr dmd-0.176/dmd/html/d/faq.html dmd-0.177/dmd/html/d/faq.html
--- dmd-0.176/dmd/html/d/faq.html 2006-11-27 18:15:56.000000000 +0100
+++ dmd-0.177/dmd/html/d/faq.html 2006-12-09 00:40:28.000000000 +0100
@@ -31,7 +31,7 @@
- Last update Mon Nov 27 18:15:55 2006
+ Last update Sat Dec 9 00:40:27 2006
@@ -502,9 +502,9 @@
double d;
- NaN's have the interesting property in that whenever a NaN is
+ NaNs have the interesting property in that whenever a NaN is
used as an operand in a computation, the result is a NaN. Therefore,
- NaN's will propagate and appear in the output whenever a computation
+ NaNs will propagate and appear in the output whenever a computation
made use of one. This implies that a NaN appearing in the output
is an unambiguous indication of the use of an uninitialized
variable.
@@ -612,13 +612,15 @@
tool.
+ with the /foo/g
+ syntax?
There are two reasons:
- - The /foo/g syntax would make it impossible to separate
+
- The /foo/g
+ syntax would make it impossible to separate
the lexer from the parser, as / is the divide token.
- There are already 3 string types; adding the regex literals
diff -uNr dmd-0.176/dmd/html/d/float.html dmd-0.177/dmd/html/d/float.html
--- dmd-0.176/dmd/html/d/float.html 2006-11-27 18:15:56.000000000 +0100
+++ dmd-0.177/dmd/html/d/float.html 2006-12-05 18:54:32.000000000 +0100
@@ -32,7 +32,7 @@
-
Last update Mon Nov 27 18:15:54 2006
+ Last update Tue Dec 5 18:54:30 2006
@@ -132,16 +132,16 @@
Floating Point Intermediate Values
- On many computers, greater
+ On many computers, greater
precision operations do not take any longer than lesser
precision operations, so it makes numerical sense to use
the greatest precision available for internal temporaries.
The philosophy is not to dumb down the language to the lowest
common hardware denominator, but to enable the exploitation
of the best capabilities of target hardware.
-
+
- For floating point operations and expression intermediate values,
+ For floating point operations and expression intermediate values,
a greater precision can be used than the type of the
expression.
Only the minimum precision is set by the types of the
@@ -150,17 +150,18 @@
it is expected (but not required) that the intermediate
calculations be done to the full 80 bits of precision
implemented by the hardware.
-
+
- It's possible that, due to greater use of temporaries and
+ It's possible that, due to greater use of temporaries and
common subexpressions, optimized code may produce a more
accurate answer than unoptimized code.
-
+
- Algorithms should be written to work based on the minimum
+ Algorithms should be written to work based on the minimum
precision of the calculation. They should not degrade or
fail if the actual precision is greater. Float or double types,
as opposed to the real (extended) type, should only be used for:
+
- reducing memory consumption for large arrays
- when speed is more important than accuracy
@@ -215,42 +216,47 @@
Complex and Imaginary types
- In existing languages, there is an astonishing amount of effort expended in trying to jam a
+ In existing languages, there is an astonishing amount of effort expended in trying to jam a
complex type onto existing type definition facilities: templates, structs, operator
overloading, etc., and it all usually ultimately fails. It fails because the semantics of
complex operations can be subtle, and it fails because the compiler doesn't know what the
programmer is trying to do, and so cannot optimize the semantic implementation.
-
+
- This is all done to avoid adding a new type. Adding a new type means that the compiler
+ This is all done to avoid adding a new type. Adding a new type means that the compiler
can make all the semantics of complex work "right". The programmer then can rely on a
correct (or at least fixable ) implementation of complex.
-
+
- Coming with the baggage of a complex type is the need for an imaginary type. An
+ Coming with the baggage of a complex type is the need for an imaginary type. An
imaginary type eliminates some subtle semantic issues, and improves performance by not
having to perform extra operations on the implied 0 real part.
-
+
- Imaginary literals have an i suffix:
+ Imaginary literals have an i suffix:
+
ireal j = 1.3i;
- There is no particular complex literal syntax, just add a real and imaginary type:
+ There is no particular complex literal syntax, just add a real and
+ imaginary type:
+
cdouble cd = 3.6 + 4i;
creal c = 4.5 + 2i;
- Complex, real and imaginary numbers have two properties:
+ Complex, real and imaginary numbers have two properties:
+
.re get real part (0 for imaginary numbers)
.im get imaginary part as a real (0 for real numbers)
- For example:
+ For example:
+
cd.re is 4.5 double
@@ -263,8 +269,10 @@
Rounding Control
- IEEE 754 floating point arithmetic includes the ability to set 4 different rounding modes.
+ IEEE 754 floating point arithmetic includes the ability to set 4
+ different rounding modes.
These are accessible via the functions in std.c.fenv.
+
Exception Flags
@@ -284,7 +292,7 @@
Floating Point Comparisons
- In addition to the usual < <= > >= == != comparison
+ In addition to the usual < <= > >= == != comparison
operators, D adds more that are
specific to floating point. These are
!<>=
@@ -298,7 +306,7 @@
and match the semantics for the
NCEG extensions to C.
See Floating point comparisons.
-
+
diff -uNr dmd-0.176/dmd/html/d/function.html dmd-0.177/dmd/html/d/function.html
--- dmd-0.176/dmd/html/d/function.html 2006-12-02 20:08:52.000000000 +0100
+++ dmd-0.177/dmd/html/d/function.html 2006-12-09 00:40:28.000000000 +0100
@@ -32,7 +32,7 @@
- Last update Sat Dec 2 20:08:51 2006
+ Last update Sat Dec 9 00:40:27 2006
@@ -177,8 +177,10 @@
overridden.
- Functions marked as final may not be overridden in a
- derived class, unless they are also private.
+ Functions marked as final
+ may not be overridden in a
+ derived class, unless they are also private
+.
For example:
class A
@@ -459,7 +461,8 @@
2
- A lazy parameter of type void can accept an argument
+ A lazy parameter of type void
+ can accept an argument
of any type.
Variadic Functions
@@ -479,7 +482,8 @@
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):
+ It has non-D linkage, such as extern (C)
+:
extern (C) int foo(int x, int y, ...);
@@ -495,10 +499,12 @@
C-style variadic functions match the C calling convention for
variadic functions, and is most useful for calling C library
- functions like printf.
+ 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
+ _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:
@@ -532,7 +538,8 @@
These variadic functions have a special local variable declared for
them,
- _argptr, which is a void* pointer to the first of the
+ _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:
@@ -547,7 +554,26 @@
An additional hidden argument
- with the name _arguments and type TypeInfo[]
+ with the name _arguments
+
+
+
+
+
+
+
+
+
+ and type TypeInfo[]
+
is passed to the function.
_arguments gives the number of arguments and the type
of each, enabling the creation of typesafe variadic functions.
@@ -1110,7 +1136,8 @@
The .ptr property of a delegate will return the
- frame pointer value as a void*.
+ frame pointer value as a void*
+.
The .funcptr property of a delegate will return the
@@ -1128,11 +1155,13 @@
main() Function
- For console programs, main() serves as the entry point.
+ For console programs, main()
+ serves as the entry point.
It gets called after all the module initializers are run, and
after any unittests are run.
After it returns, all the module destructors are run.
- main() must be declared using one of the following forms:
+ main()
+ must be declared using one of the following forms:
void main() { ... }
void main(char[][] args) { ... }
@@ -1140,25 +1169,7 @@
int main(char[][] args) { ... }
-
-
-
-
-
-
-
-
-
-
-
+)
diff -uNr dmd-0.176/dmd/html/d/future.html dmd-0.177/dmd/html/d/future.html
--- dmd-0.176/dmd/html/d/future.html 2006-11-27 18:15:56.000000000 +0100
+++ dmd-0.177/dmd/html/d/future.html 2006-12-05 18:54:32.000000000 +0100
@@ -32,7 +32,7 @@
- Last update Mon Nov 27 18:15:55 2006
+ Last update Tue Dec 5 18:54:30 2006
diff -uNr dmd-0.176/dmd/html/d/garbage.html dmd-0.177/dmd/html/d/garbage.html
--- dmd-0.176/dmd/html/d/garbage.html 2006-11-30 02:37:58.000000000 +0100
+++ dmd-0.177/dmd/html/d/garbage.html 2006-12-09 00:40:28.000000000 +0100
@@ -32,7 +32,7 @@
- Last update Thu Nov 30 02:37:57 2006
+ Last update Sat Dec 9 00:40:27 2006
@@ -332,7 +332,8 @@
A copying garbage collector may change this value.
- - Do not store magic values into pointers, other than null.
+
- Do not store magic values into pointers, other than null
+.
- Do not write pointer values out to disk and read them back in
@@ -382,11 +383,13 @@
This may result in intermediate conditions where there is
not a valid pointer, and if the gc pauses the thread in such a
condition, it can corrupt memory.
- Most implementations of memcpy() will work since the
+ Most implementations of memcpy()
+ will work since the
internal implementation of it does the copy in aligned chunks
greater than or equal to a pointer size, but since this kind of
implementation is not guaranteed by the C standard, use
- memcpy() only with extreme caution.
+ memcpy()
+ only with extreme caution.
diff -uNr dmd-0.176/dmd/html/d/glossary.html dmd-0.177/dmd/html/d/glossary.html
--- dmd-0.176/dmd/html/d/glossary.html 2006-11-27 18:15:56.000000000 +0100
+++ dmd-0.177/dmd/html/d/glossary.html 2006-12-05 18:54:32.000000000 +0100
@@ -32,7 +32,7 @@
-
Last update Mon Nov 27 18:15:55 2006
+ Last update Tue Dec 5 18:54:30 2006
diff -uNr dmd-0.176/dmd/html/d/html.html dmd-0.177/dmd/html/d/html.html
--- dmd-0.176/dmd/html/d/html.html 2006-11-27 18:15:56.000000000 +0100
+++ dmd-0.177/dmd/html/d/html.html 2006-12-05 18:54:32.000000000 +0100
@@ -32,7 +32,7 @@
- Last update Mon Nov 27 18:15:54 2006
+ Last update Tue Dec 5 18:54:30 2006
diff -uNr dmd-0.176/dmd/html/d/htod.html dmd-0.177/dmd/html/d/htod.html
--- dmd-0.176/dmd/html/d/htod.html 2006-11-27 18:15:58.000000000 +0100
+++ dmd-0.177/dmd/html/d/htod.html 2006-12-09 00:40:30.000000000 +0100
@@ -31,7 +31,7 @@
- Last update Mon Nov 27 18:15:57 2006
+ Last update Sat Dec 9 00:40:28 2006
@@ -238,7 +238,8 @@
- -hc
- By default, htod will insert the C and C++ declarations
-in a file into the output file prefixed by //C .
+in a file into the output file prefixed by //C
+.
-hc will suppress this.
Use only if you're confident that htod is generating the
correct output file (such as if the header file was modified with
@@ -247,13 +248,15 @@
- -hi
-
- By default, htod will represent a #include "file" with
+
- By default, htod will represent a #include "file"
+ with
a corresponding import statement. The -hi will cause the
declarations in the included file to be converted to D declarations as
well. The declarations in all included files are parsed regardless.
-hi is handy when replacing an entire hierarchy of include files
with a single D import.
-System includes like #include <file> are not affected
+System includes like #include <file>
+ are not affected
by -hi.
See also -hs.
@@ -308,7 +311,8 @@
void bar(int x, int y, long z);
-The C declarations are prefixed by the string "//C ".
+The C declarations are prefixed by the string "//C "
+.
Type Mappings
diff -uNr dmd-0.176/dmd/html/d/htomodule.html dmd-0.177/dmd/html/d/htomodule.html
--- dmd-0.176/dmd/html/d/htomodule.html 2006-11-30 02:37:58.000000000 +0100
+++ dmd-0.177/dmd/html/d/htomodule.html 2006-12-09 00:40:28.000000000 +0100
@@ -31,7 +31,7 @@
- Last update Thu Nov 30 02:37:57 2006
+ Last update Sat Dec 9 00:40:27 2006
@@ -189,22 +189,28 @@
- Converting C .h Files to D Modules
+ Converting C .h
+ Files to D Modules
While D cannot directly compile C source code, it can easily
interface to C code, be linked with C object files, and call
C functions in DLLs.
- The interface to C code is normally found in C .h files.
+ The interface to C code is normally found in C .h
+ files.
So, the trick to connecting with C code is in converting C
- .h files to D modules.
+ .h
+ files to D modules.
This turns out to be difficult to do mechanically since
inevitably some human judgement must be applied.
This is a guide to doing such conversions.
Preprocessor
- .h files can sometimes be a bewildering morass of layers of
- macros, #include files, #ifdef's, etc. D doesn't
+ .h
+ files can sometimes be a bewildering morass of layers of
+ macros, #include
+ files, #ifdef
+'s, etc. D doesn't
include a text preprocessor like the C preprocessor,
so the first step is to remove the need for
it by taking the preprocessed output. For DMC (the Digital
@@ -213,11 +219,15 @@
dmc -c program.h -e -l
- will create a file program.lst which is the source file after
+ will create a file program.lst
+ which is the source file after
all text preprocessing.
- Remove all the #if, #ifdef, #include,
+ Remove all the #if
+, #ifdef
+, #include
+,
etc. statements.
Linkage
@@ -286,13 +296,18 @@
NULL
- NULL and ((void*)0) should be replaced
- with null.
+ NULL
+ and ((void*)0)
+ should be replaced
+ with null
+.
Numeric Literals
Any 'L' or 'l' numeric literal suffixes should be removed,
- as a C long is (usually) the same size as a D int.
+ as a C long
+ is (usually) the same size as a D int
+.
Similarly, 'LL' suffixes should be replaced with a
single 'L'.
Any 'u' suffix will work the same in D.
@@ -419,8 +434,10 @@
Const Type Modifiers
- D has const as a storage class, not a type modifier. Hence, just
- drop any const used as a type modifier:
+ D has const
+ as a storage class, not a type modifier. Hence, just
+ drop any const
+ used as a type modifier:
void foo(const int *p, char *const q);
@@ -437,31 +454,38 @@
there will be a multiple definition error. To fix this problem,
the idea is to declare the variable in a D module, but not link
in that module. For example, given a C header file named
- foo.h:
+ foo.h
+:
struct Foo { };
struct Foo bar;
- It can be replaced with two D modules, foo.d:
+ It can be replaced with two D modules, foo.d
+:
struct Foo { }
import fooextern;
- and fooextern.d:
+ and fooextern.d
+:
Foo bar;
- The foo.obj file is linked in, and fooextern.obj
+ The foo.obj
+ file is linked in, and fooextern.obj
+
is not. While this is not the most elegant looking method, it does
work, and since it is pretty rare in C libraries to use global
variables in its interface, it isn't an issue in practice.
Typedef
- alias is the D equivalent to the C typedef:
+ alias
+ is the D equivalent to the C typedef
+:
typedef int foo;
@@ -494,8 +518,11 @@
A good D implementation by default will align struct members the
same way as the C compiler it was designed to work with. But
- if the .h file has some #pragma's to control alignment, they
- can be duplicated with the D align attribute:
+ if the .h
+ file has some #pragma
+'s to control alignment, they
+ can be duplicated with the D align
+ attribute:
#pragma pack(1)
struct Foo
@@ -559,7 +586,10 @@
}
- __cdecl, __pascal, __stdcall
+ __cdecl
+, __pascal
+, __stdcall
+
int __cdecl x;
int __cdecl foo(int a);
@@ -575,7 +605,8 @@
extern (Windows) int abc(int c);
- __declspec(dllimport)
+ __declspec(dllimport)
+
__declspec(dllimport) int __stdcall foo(int a);
@@ -585,9 +616,11 @@
export extern (Windows) int foo(int a);
- __fastcall
+ __fastcall
+
- Unfortunately, D doesn't support the __fastcall convention.
+ Unfortunately, D doesn't support the __fastcall
+ convention.
Therefore, a shim will be needed, either written in C:
int __fastcall foo(int a);
@@ -598,10 +631,12 @@
}
- and compiled with a C compiler that supports __fastcall and
+ and compiled with a C compiler that supports __fastcall
+ and
linked in, or compile the above, disassemble it with
obj2asm
- and insert it in a D myfoo shim with
+ and insert it in a D myfoo
+ shim with
inline assembler.
diff -uNr dmd-0.176/dmd/html/d/iasm.html dmd-0.177/dmd/html/d/iasm.html
--- dmd-0.176/dmd/html/d/iasm.html 2006-11-27 18:15:56.000000000 +0100
+++ dmd-0.177/dmd/html/d/iasm.html 2006-12-05 18:54:32.000000000 +0100
@@ -32,7 +32,7 @@
- Last update Mon Nov 27 18:15:54 2006
+ Last update Tue Dec 5 18:54:30 2006
diff -uNr dmd-0.176/dmd/html/d/index.html dmd-0.177/dmd/html/d/index.html
--- dmd-0.176/dmd/html/d/index.html 2006-11-27 18:15:54.000000000 +0100
+++ dmd-0.177/dmd/html/d/index.html 2006-12-05 18:54:30.000000000 +0100
@@ -32,7 +32,7 @@
- Last update Mon Nov 27 18:15:52 2006
+ Last update Tue Dec 5 18:54:28 2006
@@ -199,11 +199,9 @@
practical experience implementing compilers." -- Michael
-
"Great, just what I need.. another D in programming." -- Segfault
-
D is a systems programming language.
Its focus is on combining the power and high performance of C and C++ with
the programmer productivity of modern languages like Ruby and Python.
diff -uNr dmd-0.176/dmd/html/d/interface.html dmd-0.177/dmd/html/d/interface.html
--- dmd-0.176/dmd/html/d/interface.html 2006-11-27 18:15:56.000000000 +0100
+++ dmd-0.177/dmd/html/d/interface.html 2006-12-09 00:41:36.000000000 +0100
@@ -32,7 +32,7 @@
- Last update Mon Nov 27 18:15:54 2006
+ Last update Sat Dec 9 00:41:34 2006
@@ -227,7 +227,7 @@
d.foo();
- Interfaces can be reimplemented in derived classes:
+ Interfaces can be reimplemented in derived classes:
interface D
{
@@ -255,8 +255,9 @@
d2.foo();
- A reimplemented interface must implement all the interface
+ A reimplemented interface must implement all the interface
functions, it does not inherit them from a super class:
+
interface D
{
@@ -282,16 +283,18 @@
A COM interface is defined as one that derives from the interface
- std.c.windows.com.IUnknown. A COM interface differs from
+ 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
+
- 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.
+ an appropriate QueryInterface()
+ would have to be implemented
+ for that interface in standard COM fashion.
diff -uNr dmd-0.176/dmd/html/d/interfaceToC.html dmd-0.177/dmd/html/d/interfaceToC.html
--- dmd-0.176/dmd/html/d/interfaceToC.html 2006-11-30 02:38:00.000000000 +0100
+++ dmd-0.177/dmd/html/d/interfaceToC.html 2006-12-09 00:40:30.000000000 +0100
@@ -32,7 +32,7 @@
- Last update Thu Nov 30 02:37:58 2006
+ Last update Sat Dec 9 00:40:28 2006
@@ -173,7 +173,8 @@
- There are no __cdecl, __far, __stdcall, __declspec, or other
such C type modifiers in D. These are handled by attributes, such
- as extern (C).
+ 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
@@ -406,12 +407,12 @@
- type function(parameters) |
- type(*)(parameters) |
+ type function(parameters) |
+ type(*)(parameters) |
- type delegate(parameters) |
+ type delegate(parameters) |
no equivalent |
@@ -434,7 +435,8 @@
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:
+ the %.*s
+ format works perfectly:
void foo(char[] string)
{
@@ -449,7 +451,8 @@
An improved D function for formatted output is
- std.stdio.writef().
+ std.stdio.writef()
+.
Structs and Unions
diff -uNr dmd-0.176/dmd/html/d/intro.html dmd-0.177/dmd/html/d/intro.html
--- dmd-0.176/dmd/html/d/intro.html 2006-11-27 18:15:54.000000000 +0100
+++ dmd-0.177/dmd/html/d/intro.html 2006-12-05 18:54:30.000000000 +0100
@@ -32,7 +32,7 @@
- Last update Mon Nov 27 18:15:52 2006
+ Last update Tue Dec 5 18:54:28 2006
@@ -199,11 +199,9 @@
practical experience implementing compilers." -- Michael
-
"Great, just what I need.. another D in programming." -- Segfault
-
D is a systems programming language.
Its focus is on combining the power and high performance of C and C++ with
the programmer productivity of modern languages like Ruby and Python.
diff -uNr dmd-0.176/dmd/html/d/lazy-evaluation.html dmd-0.177/dmd/html/d/lazy-evaluation.html
--- dmd-0.176/dmd/html/d/lazy-evaluation.html 2006-11-27 18:16:00.000000000 +0100
+++ dmd-0.177/dmd/html/d/lazy-evaluation.html 2006-12-09 00:40:30.000000000 +0100
@@ -32,7 +32,7 @@
- Last update Mon Nov 27 18:15:58 2006
+ Last update Sat Dec 9 00:40:28 2006
@@ -210,10 +210,13 @@
}
-The second expression p[0] is not evaluated unless p
+ The second expression p[0]
+ is not evaluated unless p
+
is not null.
If the second expression was not lazily evaluated, it would
-generate a runtime fault if p was null.
+generate a runtime fault if p
+ was null.
While invaluable, the lazy evaluation operators have significant
@@ -264,7 +267,8 @@
but that just papers over the problem. Preprocessor macros have
well known shortcomings:
-- The logging variable is exposed in the user's namespace.
+- The logging
+ variable is exposed in the user's namespace.
- Macros are invisible to symbolic debuggers.
- Macros are global only, and cannot be scoped.
- Macros cannot be class members.
@@ -291,15 +295,18 @@
Now, the string building expression only gets evaluated if logging
is true, and encapsulation is maintained. The only trouble is that
-few are going to want to wrap expressions with { return exp; }.
+few are going to want to wrap expressions with { return exp; }
+.
So D takes it one small, but crucial, step further
(suggested by Andrei Alexandrescu).
Any expression
-can be implicitly converted to a delegate that returns either void or
+can be implicitly converted to a delegate that returns either void
+ or
the type of the expression.
-The delegate declaration is replaced by the lazy storage class
+The delegate declaration is replaced by the lazy
+ storage class
(suggested by Tomasz Stachowiak).
The functions then become:
diff -uNr dmd-0.176/dmd/html/d/lex.html dmd-0.177/dmd/html/d/lex.html
--- dmd-0.176/dmd/html/d/lex.html 2006-11-27 18:15:54.000000000 +0100
+++ dmd-0.177/dmd/html/d/lex.html 2006-12-09 00:40:28.000000000 +0100
@@ -32,7 +32,7 @@
- Last update Mon Nov 27 18:15:52 2006
+ Last update Sat Dec 9 00:40:27 2006
@@ -335,8 +335,11 @@
Comments cannot be used as token concatenators, for example,
- abc/**/def is two tokens, abc and def,
- not one abcdef token.
+ abc/**/def is two tokens, abc
+ and def
+,
+ not one abcdef
+ token.
@@ -1108,7 +1111,8 @@
parsing.
- There is currently only one special token sequence, #line.
+ There is currently only one special token sequence, #line
+.
SpecialTokenSequence
# line Integer EndOfLine
diff -uNr dmd-0.176/dmd/html/d/lisp-java-d.html dmd-0.177/dmd/html/d/lisp-java-d.html
--- dmd-0.176/dmd/html/d/lisp-java-d.html 2006-11-27 18:16:00.000000000 +0100
+++ dmd-0.177/dmd/html/d/lisp-java-d.html 2006-12-05 18:54:34.000000000 +0100
@@ -31,7 +31,7 @@
- Last update Mon Nov 27 18:15:58 2006
+ Last update Tue Dec 5 18:54:32 2006
diff -uNr dmd-0.176/dmd/html/d/memory.html dmd-0.177/dmd/html/d/memory.html
--- dmd-0.176/dmd/html/d/memory.html 2006-11-30 02:37:58.000000000 +0100
+++ dmd-0.177/dmd/html/d/memory.html 2006-12-09 00:40:28.000000000 +0100
@@ -32,7 +32,7 @@
- Last update Thu Nov 30 02:37:57 2006
+ Last update Sat Dec 9 00:40:27 2006
@@ -411,7 +411,9 @@
to run. For specialized purposes, this can be handled by
creating NewDeclarations and DeleteDeclarations.
For example, to allocate using the C runtime library's
- malloc and free:
+ malloc
+ and free
+:
import std.c.stdlib;
import std.outofmemory;
@@ -676,7 +678,8 @@
Therefore, the ISR thread should not be paused.
Threads created with the std.thread
functions will be paused. But threads created with C's
- _beginthread() or equivalent won't be, the GC
+ _beginthread()
+ or equivalent won't be, the GC
won't know they exist.
@@ -684,7 +687,8 @@
- The ISR thread cannot allocate any memory using the GC.
- This means that the global new cannot be used.
+ This means that the global new
+ cannot be used.
Nor can dynamic arrays be resized, nor can any elements be
added to associative arrays. Any use of the D runtime library
should be examined for any possibility of allocating GC memory -
diff -uNr dmd-0.176/dmd/html/d/mixin.html dmd-0.177/dmd/html/d/mixin.html
--- dmd-0.176/dmd/html/d/mixin.html 2006-11-27 18:15:56.000000000 +0100
+++ dmd-0.177/dmd/html/d/mixin.html 2006-12-05 18:54:32.000000000 +0100
@@ -32,7 +32,7 @@
- Last update Mon Nov 27 18:15:54 2006
+ Last update Tue Dec 5 18:54:30 2006
diff -uNr dmd-0.176/dmd/html/d/module.html dmd-0.177/dmd/html/d/module.html
--- dmd-0.176/dmd/html/d/module.html 2006-11-27 18:15:54.000000000 +0100
+++ dmd-0.177/dmd/html/d/module.html 2006-12-05 18:54:30.000000000 +0100
@@ -32,7 +32,7 @@
- Last update Mon Nov 27 18:15:52 2006
+ Last update Tue Dec 5 18:54:28 2006
@@ -209,7 +209,7 @@
Example:
-module c.stdio; |