diff -uNr dmd-0.147/dmd/html/d/abi.html dmd-0.148/dmd/html/d/abi.html --- dmd-0.147/dmd/html/d/abi.html 2006-02-10 17:17:06.000000000 +0100 +++ dmd-0.148/dmd/html/d/abi.html 2006-02-25 11:48:36.000000000 +0100 @@ -25,7 +25,7 @@ | Comments -
Last update Fri Feb 10 17:17:04 2006 +
Last update Sat Feb 25 11:48:35 2006
diff -uNr dmd-0.147/dmd/html/d/acknowledgements.html dmd-0.148/dmd/html/d/acknowledgements.html --- dmd-0.147/dmd/html/d/acknowledgements.html 2006-02-10 17:17:06.000000000 +0100 +++ dmd-0.148/dmd/html/d/acknowledgements.html 2006-02-25 11:48:36.000000000 +0100 @@ -25,7 +25,7 @@ | Comments -
Last update Fri Feb 10 17:17:04 2006 +
Last update Sat Feb 25 11:48:35 2006
@@ -88,6 +88,9 @@ · Rationale
+ · Exception Safety
+ + · Glossary
@@ -112,6 +115,9 @@ · Code Coverage
+ · DMD Script Shell
+ +
Community
diff -uNr dmd-0.147/dmd/html/d/arrays.html dmd-0.148/dmd/html/d/arrays.html --- dmd-0.147/dmd/html/d/arrays.html 2006-02-15 13:49:02.000000000 +0100 +++ dmd-0.148/dmd/html/d/arrays.html 2006-02-25 11:48:36.000000000 +0100 @@ -25,7 +25,7 @@ | Comments -
Last update Wed Feb 15 13:49:00 2006 +
Last update Sat Feb 25 11:48:34 2006
@@ -328,20 +328,6 @@ int[] b = p[0..8]; - Slicing for bit arrays is only allowed if the slice's lower - bound falls on a byte boundary: - -
bit[] b;
-...
-b[0..8];	// ok
-b[8..16];	// ok
-b[8..17];	// ok
-b[1..16];	// error, lower bound is not on a byte boundary
-
- - Misaligned bit array slices will cause an ArrayBoundsError exception - to be thrown at runtime. -

Array Copying

When the slice operator appears as the lvalue of an assignment @@ -778,25 +764,6 @@

Special Array Types

-

Arrays of Bits

- - Bit vectors can be constructed: - -
bit[10] x;		// array of 10 bits
-
- - The amount of storage used up is implementation dependent. - Implementation Note: on - Intel CPUs it would be rounded up to the next 32 bit size. - -
x.length		// 10, number of bits
-x.size			// 4,  bytes of storage
-
- - So, the size per element is not (x.size / x.length). - - -

Strings

Languages should be good at handling strings. C and C++ are not diff -uNr dmd-0.147/dmd/html/d/attribute.html dmd-0.148/dmd/html/d/attribute.html --- dmd-0.147/dmd/html/d/attribute.html 2006-02-10 17:17:04.000000000 +0100 +++ dmd-0.148/dmd/html/d/attribute.html 2006-02-25 11:48:36.000000000 +0100 @@ -25,7 +25,7 @@ | Comments -
Last update Fri Feb 10 17:17:03 2006 +
Last update Sat Feb 25 11:48:34 2006
diff -uNr dmd-0.147/dmd/html/d/builtin.html dmd-0.148/dmd/html/d/builtin.html --- dmd-0.147/dmd/html/d/builtin.html 1970-01-01 01:00:00.000000000 +0100 +++ dmd-0.148/dmd/html/d/builtin.html 2006-02-25 11:48:38.000000000 +0100 @@ -0,0 +1,273 @@ + + + + + + + + +D Programming Language - D Builtin Rationale + + + + +
+ www.digitalmars.com + + Home + | Search + | D + | Comments + +
Last update Sat Feb 25 11:48:36 2006 +
+
+ + + + + + + + +
+ +
+
+ + + + + +
+
+ +
+D
+Language
+Phobos
+Comparisons +
+
+ +· D vs C/C++/C#/Java
+ + +· Rationale for Builtins
+ + +· Converting C to D
+ + +· Converting C++ to D
+ + +· The C Preprocessor vs D
+ + +· D strings vs C++ std::string
+ + +· D complex vs C++ std::complex
+ + +· D Contract Programming vs C++
+ + +
+
+ + +

Core Language Features vs Library Implementation

+ + + D offers several capabilities built in to the core language + that are implemented as libraries in other languages such + as C++: + +
    +
  1. Dynamic Arrays +
  2. Strings +
  3. Associative Arrays +
  4. Complex numbers +
+ + Some consider this as evidence of language bloat, rather than + a useful feature. + So why not implement each of these as standardized library types? +

+ + Some general initial observations: +

    + +
  1. Each of them is heavilly used. This means that even small + improvements in usability are worth reaching for. + +
  2. Being a core language feature means that the compiler can + issue better and more to the point error messages when a type + is used incorrectly. + Library implementations tend to give notoriously obtuse messages + based on the internal details of those implementations. + +
  3. Library features cannot invent new syntax, new operators, + or new tokens. + +
  4. Library implementations tend to require a lot of compile + time processing of the implementation, over and over for each compile, + that slows down compilation. + +
  5. Library implementations are supposed to provide flexibility + to the end user. But if they are standardized, standardized to the + point of the compiler being allowed to recognized them as special + (the C++ Standard allows this), then they become just as inflexible + as builtin core features. + +
  6. The ability to define new library types, while having greatly + advanced in the last few years, still leaves a lot to be desired + in smoothly integrating it into the existing language. + Rough edges, clumsy syntax, and odd corner cases abound. + +
+ + More specific comments: + +

Dynamic Arrays

+ + C++ has builtin core arrays. It's just that they don't work very + well. Rather than fix them, several different array types were + created as part of the C++ Standard Template Library, each covering + a different deficiency in the builtin arrays. These + include: + +
    +
  • basic_string +
  • vector +
  • valarray +
  • deque +
  • slice_array +
  • gslice_array +
  • mask_array +
  • indirect_array +
+ + Fixing the builtin array support means the need for each of these + variations just evaporates. There's one array type that covers + it all, only one thing to learn, and no problems getting one array + type to work with another array type. +

+ + As usual, a builtin type lets us create syntactic sugar for it. + This starts with having an array literal, and follows with some + new operators specific to arrays. A library array implementation + has to make due with overloading existing operators. + The indexing operator, a[i], it shares with C++. + Added are the array concatenation operator ~, array append operator + ~=, array slice operator a[i..j], + and the array vector operator + a[]. +

+ + The ~ and ~= concatenation operators resolve a problem that comes + up when only existing operators can be overloaded. Usually, + is + pressed into service as concatenation for library array + implementations. But that winds up precluding having + mean + array vector addition. Furthermore, concatenation has nothing in + common with addition, and using the same operator for both is + confusing. + +

Strings

+ + A detailed comparison with C++'s std::string. + + C++ has, of course, builtin string support in the form of string + literals and char arrays. It's just that they suffer from all + the weaknesses of C++ builtin arrays. +

+ + But after all, what is a string if not an array of characters? + If the builtin array problems are fixed, doesn't that resolve + the string problems as well? It does. It seems odd at first that + D doesn't have a string class, but since manipulating strings + is nothing more than manipulating arrays of characters, if arrays + work, there's nothing a class adds to it. +

+ + Furthermore, the oddities resulting from builtin string literals + not being of the same type as the library string class type go + away. + +

Associative Arrays

+ + The main benefit for this is, once again, syntactic sugar. + An associative array keying off of a type T and storing an + int value is naturally written + as: + +
int[T] foo;
+
+ + rather than: + +
import std.associativeArray;
+...
+std.associativeArray.AA!(T, int) foo;
+
+ + Builtin associative arrays also offer the possibility of having + associative array literals, which are an often requested additional + feature. + +

Complex Numbers

+ + A detailed comparison with C++'s std::complex. +

+ + The most compelling reason is compatibility with C's imaginary + and complex floating point types. + Next, is the ability to have imaginary floating point literals. + Isn't: + +

c = (6 + 2i - 1 + 3i) / 3i;
+
+ + far preferable than writing: + +
c = (complex!(double)(6,2) + complex!(double)(-1,3)) / complex!(double)(0,3);
+
+ + ? It's no contest. + + +
+ + + + + + + + + + + + + + + diff -uNr dmd-0.147/dmd/html/d/changelog.html dmd-0.148/dmd/html/d/changelog.html --- dmd-0.147/dmd/html/d/changelog.html 2006-02-15 13:49:02.000000000 +0100 +++ dmd-0.148/dmd/html/d/changelog.html 2006-02-25 18:09:16.000000000 +0100 @@ -25,7 +25,7 @@ | Comments -
Last update Wed Feb 15 13:49:00 2006 +
Last update Sat Feb 25 18:09:14 2006
@@ -88,6 +88,9 @@ · Rationale
+ · Exception Safety
+ + · Glossary
@@ -112,6 +115,9 @@ · Code Coverage
+ · DMD Script Shell
+ +
Community
@@ -165,6 +171,8 @@