Cours the D Programming Language, tutoriel & guide de travaux pratiques en pdf.
The D Programming Language
• Systems programming language inspired by C++
• Created by Walter Bright, first native C++ compiler
• Supported by Andrei Alexandrescu, Modern C++ Design
• Community driven, open-source (Not GPL)
• Multi-platform (Windows, Linux, FreeBSD, OSX)
• Multi-paradigm (IP, OOP, FP, DBC, TDD)
High performance
• Systems language
– Direct access to OS, C, C++ APIs
• Compiles to native code
• Support for inline assembly
• Compile-time function evaluation
• Built-in profiler and code coverage tool
Improved productivity
• No pre-processor, no header files
• All types are platform independent
– int is always 32 bit; long is always 64 bit
• Built-in arrays and associative arrays
– Arrays know their length and can be resized
– Strings are arrays of Unicode characters
• Support for unit-tests, contracts, invariants
• Meta-programming (code generation)
Native COM support
• The D compiler recognizes IUnknown
– COM virtual function table layout
– STDMETHODCALL calling convention
• “Look Mom, no marshaling!”
D’s modern feature set
• Type deduction auto ptr = CoTaskMemAlloc(1000);
• Scope guards (RAII) scope(exit) CoTaskMemFree(ptr);
• Closures auto square = (int i) { return i*i; };
• Safe variadic arguments (uses RTTI) writefln(« %s %s %s », « abc », 2, 5.6);
• Universal iteration
foreach (key, value; myHashTable) …
Modern COM programming 101
• Encapsulate the COM interface
– Create a new type that mimics the interface
– Smart pointer semantics
– Same number of methods
• Use this new type from your app
– Never access the raw interface
• Inside each method:
1. Convert input parameter(s)
2. Call raw COM method
3. Check HRESULT, if FAILED throw
4. Convert output parameter(s)
Sommaire
1.Modern COM Programming?
2.The D Programming Language
3.Projecting COM interfaces
4.Under the hood
5.Hands on!
