.sizeof |
Returns the array length multiplied by the number of
bytes per array element.
@@ -606,28 +609,30 @@
- The .length property of a dynamic array can be set
+ The .length property of a dynamic array can be set
as the lvalue of an = operator:
+
array.length = 7;
- This causes the array to be reallocated in place, and the existing
+ This causes the array to be reallocated in place, and the existing
contents copied over to the new array. If the new array length is
shorter,
only enough are copied to fill the new array. If the new array length
is longer, the remainder is filled out with the default initializer.
-
+
- To maximize efficiency, the runtime always tries to resize the
+ To maximize efficiency, the runtime always tries to resize the
array in place to avoid extra copying. It will always do a copy
if the new size is larger and the array was not allocated via the
new operator or a previous
resize operation.
-
+
- This means that if there is an array slice immediately following the
+ This means that if there is an array slice immediately following the
array being resized, the resized array could overlap the slice; i.e.:
+
char[] a = new char[20];
char[] b = a[0..10];
@@ -649,16 +654,17 @@
- To guarantee copying behavior, use the .dup property to ensure
+ To guarantee copying behavior, use the .dup property to ensure
a unique array that can be resized.
-
+
- These issues also apply to concatenating arrays with the ~ and ~=
+ These issues also apply to concatenating arrays with the ~ and ~=
operators.
-
+
- Resizing a dynamic array is a relatively expensive operation.
+ Resizing a dynamic array is a relatively expensive operation.
So, while the following method of filling an array:
+
int[] array;
while (1)
@@ -670,8 +676,9 @@
}
- will work, it will be inefficient. A more practical
+ will work, it will be inefficient. A more practical
approach would be to minimize the number of resizes:
+
int[] array;
array.length = 100;
- Picking a good initial guess is an art, but you usually can
+ Picking a good initial guess is an art, but you usually can
pick a value covering 99% of the cases.
For example, when gathering user
input from the console - it's unlikely to be longer than 80.
+
Functions as Array Properties
@@ -706,12 +714,13 @@
- It is an error to index an array with an index that is less than
+ It is an error to index an array with an index that is less than
0 or greater than or equal to the array length. If an index is
out of bounds, an ArrayBoundsError exception is raised if detected
at runtime, and an error if detected at compile time.
A program may not rely on array bounds checking happening, for
example, the following program is incorrect:
+
try
{
@@ -734,37 +743,40 @@
}
- Implementation Note: Compilers should attempt to detect
+ Implementation Note: Compilers should attempt to detect
array bounds errors at compile time, for example:
+
int[3] foo;
int x = foo[3];
- Insertion of array bounds checking code at runtime should be
+ Insertion of array bounds checking code at runtime should be
turned on and off
with a compile time switch.
+
Array Initialization
Default Initialization
- - Pointers are initialized to null.
-
- Static array contents are initialized to the default
- initializer for the array element type.
-
- Dynamic arrays are initialized to having 0 elements.
-
- Associative arrays are initialized to having 0 elements.
+
- Pointers are initialized to null.
+ - Static array contents are initialized to the default
+ initializer for the array element type.
+ - Dynamic arrays are initialized to having 0 elements.
+ - Associative arrays are initialized to having 0 elements.
Void Initialization
- Void initialization happens when the Initializer for
+ Void initialization happens when the Initializer for
an array is void. What it means is that no initialization
is done, i.e. the contents of the array will be undefined.
This is most useful as an efficiency optimization.
Void initializations are an advanced technique and should only be used
when profiling indicates that it matters.
+
Static Initialization of Static Arrays
@@ -805,12 +817,12 @@
str[0] = 'b';
- char[] strings are in UTF-8 format.
+ char[] strings are in UTF-8 format.
wchar[] strings are in UTF-16 format.
dchar[] strings are in UTF-32 format.
-
+
- Strings can be copied, compared, concatenated, and appended:
+ Strings can be copied, compared, concatenated, and appended:
str1 = str2;
if (str1 < str3) ...
@@ -818,21 +830,23 @@
str4 ~= str1;
- with the obvious semantics. Any generated temporaries get cleaned up
+ with the obvious semantics. Any generated temporaries get cleaned up
by the garbage collector (or by using alloca()). Not only that,
this works with any
array not just a special String array.
-
+
- A pointer to a char can be generated:
+ A pointer to a char can be generated:
+
char* p = &str[3]; char* p = str;
- Since strings, however, are not 0 terminated in D,
+ Since strings, however, are not 0 terminated in D,
when transferring a pointer
to a string to C, add a terminating 0:
+
str ~= "\0";
@@ -964,14 +978,16 @@
func(b["hello"]);
- Particular keys in an associative array can be removed with the
+ Particular keys in an associative array can be removed with the
remove function:
+
b.remove("hello");
- The InExpression yields a pointer to the value
+ The InExpression yields a pointer to the value
if the key is in the associative array, or null if not:
+
int* p;
p = ("hello" in b);
@@ -979,19 +995,20 @@
...
- KeyTypes cannot be functions or voids.
-
+ KeyTypes cannot be functions or voids.
+
- If the KeyType is a struct type, a default mechanism is used
+ If the KeyType is a struct type, a default mechanism is used
to compute the hash and comparisons of it based on the binary
data within the struct value. A custom mechanism can be used
by providing the following functions as struct members:
+
uint toHash();
int opCmp(KeyType* s);
- For example:
+ For example:
import std.string;
@@ -1104,33 +1121,38 @@
Properties for associative arrays are:
-
- .sizeof
+ | .sizeof |
Returns the size of the reference to the associative
array; it is typically 8.
+ |
+
-
- .length
+ | .length |
Returns number of values in the associative array.
Unlike for dynamic arrays, it is read-only.
+ |
+
-
- .keys
+ | .keys |
Returns dynamic array, the elements of which are the keys in
the associative array.
+ |
+
-
- .values
+ | .values |
Returns dynamic array, the elements of which are the values in
the associative array.
+ |
+
-
- .rehash
+ | .rehash |
Reorganizes the associative array in place so that lookups
are more efficient. rehash is effective when, for example,
the program is done loading up a symbol table and now needs
fast lookups in it.
Returns a reference to the reorganized array.
+ |
+
diff -uNr dmd-1.023/dmd/html/d/changelog.html dmd-1.024/dmd/html/d/changelog.html
--- dmd-1.023/dmd/html/d/changelog.html 2007-11-01 11:21:22.000000000 +0100
+++ dmd-1.024/dmd/html/d/changelog.html 2007-11-27 21:19:32.000000000 +0100
@@ -34,17 +34,191 @@
- Last update Thu Nov 1 11:21:21 2007
+ Last update Tue Nov 27 21:19:30 2007
-$(D_S D Change Log,
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ D Change Log
+
+ - What's new for D 1.024
+
- What's new for D 1.023
- What's new for D 1.022
@@ -104,6 +278,34 @@
+
+
+
+Nov 27, 2007
+
+New/Changed Features
+
+ - Changed the way coverage analysis is done so it is independent
+ of order dependencies among modules.
+
+
+Bugs Fixed
+
+ - Bugzilla 70: valgrind: Conditional jump or move depends on uninitialised value(s) in elf_findstr
+ - Bugzilla 71: valgrind: Invalid read of size 4 in elf_renumbersyms
+ - Bugzilla 204: Error message on attempting to instantiate an abstract class needs to be improved
+ - Bugzilla 1508: dmd/linux template symbol issues
+ - Bugzilla 1656: illegal declaration accepted
+ - Bugzilla 1664: (1.23).stringof generates bad code
+ - Bugzilla 1665: Internal error: ..\ztc\cod2.c 411
+
+
+
+
+
- Bugzilla 726: incorrect error line for "override" mixin
- Bugzilla 729: scope(...) statement in SwitchBody causes compiler to segfault
- Bugzilla 733: std.conv.toFloat does not catch errors
+ - Bugzilla 1258: Garbage collector loses memory upon array concatenation
- Bugzilla 1478: Avoid libc network api threadsafety issues
+ - Bugzilla 1480: std.stream throws the new override warning all over the place
- Bugzilla 1483: Errors in threads not directed to stderr
- Bugzilla 1491: Suppress SIGPIPE when sending to a dead socket
+ - Bugzilla 1557: std.zlib allocates void[]s instead of ubyte[]s, causing leaks.
- Bugzilla 1562: Deduction of template alias parameter fails
- Bugzilla 1575: Cannot do assignment of tuples
- Bugzilla 1593: ICE compiler crash empty return statement in function
@@ -182,6 +387,7 @@
- Bugzilla 1531: cannot access typedef'd class field
- Bugzilla 1537: Internal error: ..\ztc\cgcod.c 1521
- Bugzilla 1609: TypeInfo_Typedef has incorrect implementation of next()
+
@@ -872,7 +1078,24 @@
Bugzilla 826: ICE: is-expression with invalid template instantiation
-
+
+
+
+
+
+
+
+
+
+
diff -uNr dmd-1.023/dmd/html/d/cppstrings.html dmd-1.024/dmd/html/d/cppstrings.html
--- dmd-1.023/dmd/html/d/cppstrings.html 2007-10-05 00:38:20.000000000 +0200
+++ dmd-1.024/dmd/html/d/cppstrings.html 2007-11-27 21:19:30.000000000 +0100
@@ -35,7 +35,7 @@
- Last update Fri Oct 5 00:38:18 2007
+ Last update Tue Nov 27 21:19:29 2007
@@ -385,7 +385,7 @@
int inword;
int wstart;
- input = cast(char[])file.read(args[i]);
+ input = cast(char[])std.file.read(args[i]);
for (int j = 0; j < input.length; j++)
{ char c;
diff -uNr dmd-1.023/dmd/html/d/dcompiler.html dmd-1.024/dmd/html/d/dcompiler.html
--- dmd-1.023/dmd/html/d/dcompiler.html 2007-10-05 00:38:22.000000000 +0200
+++ dmd-1.024/dmd/html/d/dcompiler.html 2007-11-27 21:19:32.000000000 +0100
@@ -25,8 +25,7 @@
- Last update Fri Oct 5 00:38:21 2007
+ Last update Tue Nov 27 21:19:30 2007
@@ -223,22 +222,51 @@
Downloads
- - Download latest version of
-
- dmd.zip (D compiler) for Win32 and Linux
-
-
-
+
dmd downloads
+ Download |
+ Version |
+ Operating System |
+ Product |
+
+
+ dmd.zip |
+ 1.015 stable |
+ Win32 and x86 Linux |
+ dmd D 1.0 compiler |
+
+
+ dmd.2.007.zip |
+ 2.007 alpha |
+ Win32 and x86 Linux |
+ dmd D 2.0 compiler |
+
+
+ changelog |
+ all |
+ Win32 and x86 Linux |
+ other dmd versions |
+
+
+ dmc.zip |
+ 8.50 |
+ Win32 |
+ Linker and Utilities |
+
+
+
+
+
+ - GDC for Ubuntu Gutsy Gibbon: sudo apt-get install gdc
+
+
Files Common to Win32 and Linux
@@ -259,17 +287,14 @@
-
+
Requirements and Downloads
- - 32 bit Windows (Win32) operating system, such as Windows XP
+
- 32 bit Windows (Win32) operating system, such as Windows XP
- - Download
-
- dmd.zip (D compiler) for Win32
-
+ - Download dmd
- Download
@@ -399,11 +424,15 @@
not compiling for symbolic debugging instead of phobos.lib
- -g
-
- add CodeView 4 symbolic debug info
+ - add CodeView 4 symbolic debug info with
+ D extensions
+ for debuggers such as
+ Ddbg
- -gc
- add CodeView 4 symbolic debug info in C format
- (for C debuggers)
+ for debuggers such as
+ \dmd\bin\windbg
- -H
@@ -591,17 +620,7 @@
- 32 bit x86 Linux operating system
- - Download
-
- dmd.zip (D compiler) for Linux
-
-
-
-
+ - Download dmd
- Gnu C compiler (gcc)
@@ -724,11 +743,19 @@
- -fPIC
- generate position independent code
-
- -g
- - add symbolic debug info
+
+
- -g
+
- add Dwarf symbolic debug info with
+ D extensions
+ for debuggers such as
+ ZeroBUGS
+
- -gc
-
- add symbolic debug info in C format (for older gdb's)
+ - add Dwarf symbolic debug info in C format
+ for debuggers such as
+ gdb
+
- -H
- generate D interface file
@@ -932,8 +959,7 @@
Copyright © 1999-2007 by Digital Mars, All Rights Reserved
|
Page generated by Ddoc. |
-Comments
+Comments
|