Difference between revisions of "Differences With TDPL"

From D Wiki
Jump to: navigation, search
m (IFTI now uses the tail-const type of arrays and pointers: - add link)
(Mention other major DIPs and add link to accepted DIPs)
 
(9 intermediate revisions by 3 users not shown)
Line 11: Line 11:
 
http://dlang.org/expression.html#Lambda
 
http://dlang.org/expression.html#Lambda
  
=== New Alias Syntax, Alias Templates ===
+
=== New Alias Syntax, Alias & Enum Templates ===
 
http://dlang.org/declaration.html#AliasDeclaration
 
http://dlang.org/declaration.html#AliasDeclaration
 +
https://github.com/dlang/DIPs/blob/master/DIPs/archive/DIP42.md
  
 
=== Attribute Inference for Templates and Function Literals ===
 
=== Attribute Inference for Templates and Function Literals ===
Line 21: Line 22:
 
http://forum.dlang.org/post/mfjmysleuwfohoxcslpf@forum.dlang.org
 
http://forum.dlang.org/post/mfjmysleuwfohoxcslpf@forum.dlang.org
  
== Unimplemented Features ==
+
=== DIP25 - return ref ===
 +
https://dlang.org/spec/function.html#return-ref-parameters
 +
 
 +
=== DIP60 - @nogc function attribute ===
 +
https://wiki.dlang.org/DIP60
 +
 
 +
=== DIP1000 - scoped pointers ===
 +
https://github.com/dlang/DIPs/blob/master/DIPs/DIP1000.md#fundamentals-of-scope
 +
 
 +
=== DIP1010 - static foreach ===
 +
https://github.com/dlang/DIPs/blob/master/DIPs/DIP1010.md
 +
 
 +
=== Other DIPs ===
 +
 
 +
* Copy constructors
 +
* Named arguments
 +
* @system variables
 +
 
 +
See https://github.com/dlang/DIPs/tree/master/DIPs#accepted-dips.
 +
 
 +
== Unimplemented / Incomplete Features ==
  
 
=== Multiple alias this ===
 
=== Multiple alias this ===
Line 27: Line 48:
 
You can only have one subtyping member currently.
 
You can only have one subtyping member currently.
  
=== Shared ===
+
=== Synchronized Classes ===
  
Not all of shared's guarantees are implemented yet.
+
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 [https://issues.dlang.org/show_bug.cgi?id=24269 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.
  
=== SafeD ===
+
=== Shared ===
  
@safe (and therefore SafeD) isn't fully implemented. So, it doesn't
+
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.
necessarily work quite like it's supposed to yet.
 
  
 
== Differences ==
 
== Differences ==
Line 45: Line 65:
 
changed. You can look at http://d.puremagic.com/issues/show_bug.cgi?id=4542  
 
changed. You can look at http://d.puremagic.com/issues/show_bug.cgi?id=4542  
 
for details.
 
for details.
 +
 +
[[Category:Learn]]

Latest revision as of 12:30, 29 March 2024

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.

New Features

Weak vs Strong Purity

http://klickverbot.at/blog/2012/05/purity-in-d/

New Lambda Syntax

http://dlang.org/expression.html#Lambda

New Alias Syntax, Alias & Enum Templates

http://dlang.org/declaration.html#AliasDeclaration https://github.com/dlang/DIPs/blob/master/DIPs/archive/DIP42.md

Attribute Inference for Templates and Function Literals

http://dlang.org/function.html#function-attribute-inference

IFTI now uses the tail-const type of arrays and pointers

For example code, see: http://forum.dlang.org/post/mfjmysleuwfohoxcslpf@forum.dlang.org

DIP25 - return ref

https://dlang.org/spec/function.html#return-ref-parameters

DIP60 - @nogc function attribute

https://wiki.dlang.org/DIP60

DIP1000 - scoped pointers

https://github.com/dlang/DIPs/blob/master/DIPs/DIP1000.md#fundamentals-of-scope

DIP1010 - static foreach

https://github.com/dlang/DIPs/blob/master/DIPs/DIP1010.md

Other DIPs

  • Copy constructors
  • Named arguments
  • @system variables

See https://github.com/dlang/DIPs/tree/master/DIPs#accepted-dips.

Unimplemented / Incomplete Features

Multiple alias this

You can only have one subtyping member currently.

Synchronized Classes

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.

Shared

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.

Differences

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.