Differences With TDPL
The following is a list of differences between D2 and The D Programming Language book by Andrei Alexandrescu.
These need to be verified. This list was simply gathered from a post by Jonathan M. Davis on the NG to get this page started.
- 1 New Features
- 1.1 Weak vs Strong Purity
- 1.2 New Lambda Syntax
- 1.3 New Alias Syntax, Alias & Enum Templates
- 1.4 Attribute Inference for Templates and Function Literals
- 1.5 IFTI now uses the tail-const type of arrays and pointers
- 1.6 DIP25 - return ref
- 1.7 DIP60 - @nogc function attribute
- 1.8 DIP1000 - scoped pointers
- 1.9 DIP1010 - static foreach
- 2 Unimplemented / Incomplete Features
- 3 Differences
Weak vs Strong Purity
New Lambda Syntax
New Alias Syntax, Alias & Enum Templates
Attribute Inference for Templates and Function Literals
IFTI now uses the tail-const type of arrays and pointers
For example code, see: http://email@example.com
DIP25 - return ref
DIP60 - @nogc function attribute
DIP1000 - scoped pointers
DIP1010 - static foreach
Unimplemented / Incomplete Features
Multiple alias this
You can only have one subtyping member currently.
For the most part, synchronized for classes currently acts like it does in Java with synchronized being on functions. The compiler does complain about having public members if a class is marked as synchronized, but none of the stuff like automatically stripping off the outer layer of shared in member functions is implemented, and the compiler allows you to put synchronized on individual functions without putting it on the class, which TDPL explicitly says is disallowed.
Not all of shared's guarantees are implemented yet. In particular, shared has no implicit memory barriers, and it's not clear that it ever will (they're not cheap). shared is usable as-is via atomic operations (as described in TDPL) or locking mutexes (be it explicit or via synchronized), but without synchronized classes, using shared typically requires temporarily, explicitly casting shared away after protecting the object with a lock so that it can be operated on as if it were thread-local while protected by the lock.
Overriding private methods
According to TDPL, you can override private, but right now only public and protected functions are virtual. I'm not sure that it's 100% clear whether the compiler will be changed to match or whether TDPL is going to have to be changed. You can look at http://d.puremagic.com/issues/show_bug.cgi?id=4542 for details.