Log In
0% completed
All Lessons
Free Lessons (14)
Introduction
What to Expect
Lifetimes, null Value and the is Operator
Lifetimes
Fundamental Operations
Null Value & is Operator
Assigning the null Value
Summary
Quiz on Lifetimes, null Values and is Operator
Type Conversions
Automatic Type Conversions
Arithmetic and Slice Conversions
const, enum, immutable, and bool Conversions
Explicit Type Conversions
Summary
Quiz on Type Conversions
Structs
Definition of Structs
Construction
Copying and Assignment
Struct Literals and Static Members
Challenge: Lets Play Cards
Solution: Lets Play Cards
Quiz on Structs
Variable Number of Parameters
Default Arguments
Special Keywords as Default Arguments
Variadic Functions
Variadic Function Arguments Lifetime
Challenge: Perform the Calculation
Solution: Perform the Calculation
Quiz on Default Arguments and Variadic Functions
Function Overloading and Member Functions
Function Overloading and Overload Resolution
Function Overloading for User-Defined Types
Challenge: Overload a Function
Solution: Overload a Function
Member Functions
Member Function Example
const ref Parameters
const and inout Member Functions
Quiz on Functions Overloading and Member Functions
Constructor and Other Special Functions
Constructor: Introduction
Compiler-Generated Constructor
User-Defined Constructors and the Use of static opCall()
Constructor Qualifiers
Immutability and Type Conversions
Destructor
Postblit
Assignment Operator
Summary
Quiz on Constructors
Operator Overloading
Learn Operator Overloading
Overloadable Operators
Element Indexing and Slicing Operators
Defining Multiple Operators
Return Types of Operators
opEquals()
opCmp()
opCall()
Indexing Operators
Slicing Operators
opCast()
opDispatch() and opBinaryRight()
Challenge: Make the Unit Tests Pass
Solution: Make the Unit Tests Pass
Quiz on Operator Overloading
Introduction to Classes
Comparing With Structs
Copying and Assignment
Definition, Construction, and Destruction
Member Access and Member Functions
The is and !is Operator
Summary
Quiz on Classes
Inheritance
Introduction
Inheritance Hierarchy
Superclass Members
Overriding the Definitions of Member Functions
Using the Subclass in Place of the Superclass
Abstract Member Functions and Abstract Classes
Example
Challenge: Implement Inheritance Hierarchy
Solution: Implement Inheritance Hierarchy
Summary
Quiz on Inheritance
The Object Class
typeid and TypeInfo
toString and opEquals
opCmp
toHash
Challenge: Implement opEquals Function for a Class
Solution: Implement opEquals Function for a Class
Quiz on Object
Interfaces
Interface Inheritance
static Member Functions
final Member Functions
Abstraction
Example
Summary
Quiz on Interfaces
destroy and scoped
destroy()
destroy() Example
scoped()
Quiz on destroy( ) and scoped()
Modules and Libraries
Module
Importing Modules
Libraries
Quiz on Modules and Libraries
Encapsulation and Protection Attributes
Encapsulation
Protection Attributes
Module Imports and the Use of Encapsulation
Example of Encapsulation in D
Quiz on Encapsulation and Protection Attributes
UFCS, Properties and Contract Programming
Universal Function Call Syntax
Properties
Property Functions
Use of Properties
Preconditions and Postconditions
invariant Blocks
Contract Inheritance
Quiz on UFCS , Properties and Contract Programming
Templates
Introduction
Function Templates
Type Deduction and Explicit Type Specification
Template Instantiation and Template Specializations
Struct and Class Templates
Default Template Parameters and Template Instantiation
Class Template Example
Function Template Example
Quiz on Templates
Pragmas, alias and with
pragma(msg) and pragma(lib)
pragma(inline)
pragma(startaddress) and pragma(mangle)
alias: Shortening a Long Name
alias: Design Flexibility
alias: Revealing Hidden Names of Superclasses
alias this
with
Quiz on Pragmas, alias and with
Pointers
The Concept of a Reference
Syntax
Pointer Value and the Address-of Operator &
The Access Operator and the Dot Operator
Modifying the Value of a Pointer
Use of Pointers with Arrays
void* Pointers and Pointers in Logical Expressions
Use of new, .ptr and in Operator with Pointers
When to Use Pointers
Example: A Simple Linked List
Example: Observing the Contents of Memory by ubyte*
Challenge: Swap the Numbers
Solution: Swap the Numbers
Quiz on Pointers
Bit Operations
Representation of data at the lowest level
Binary Number System
Hexadecimal Number System
Bit Operations
Semantics
Common Uses
Challenge: Convert ipv4 Address to its Dotted Form
Solution: Convert ipv4 Address to its Dotted Form
Challenge: Convert Four Octet Values to the Corresponding 32-bit
Solution: Convert Four Octet Values to the Corresponding 32-bit
Challenge: Make a Mask of Specified Width
Solution: Make a Mask of Specified Width
Quiz on Bit Operations
Conditional Compilation
Introduction
debug
version(tag) and version(level)
static(if), static(assert) and Type Traits
is Expression
is (T == Specifier)
is (T identifier == Specifier)
is (/* ... */ Specifier, TemplateParamList)
Quiz on Conditional Compilation
Function Pointers, Delegates, and Lambdas
Function Pointers
Function Pointer as a Parameter & a Member
Anonymous Functions
Delegates
Delegate Properties, Lazy Parameters & Lazy Variadic Functions
`toString()` with a Delegate Parameter
Chapter Summary
Quiz on Function Pointers, Delegates, and Lambdas
foreach with Structs and Classes
foreach Support by Range Member Functions
opApply & opApplyReverse Member Functions
Loop Counter
Challenge: Designing a NumberRange Struct
Solution: Design a NumberRange Struct
Nested Functions, Structs, and Classes
Quiz on Use of foreach with Struct and Classes
Unions, Labels, goto and Tuples
Unions
Anonymous Unions and Dissecting Other Members
union Examples
Labels and goto
Tuples: tuple()
Tuples: AliasSeq
Tuples: .tupleof property
Quiz on Unions, Labels, goto, and Tuples
More Templates
The Shortcut Syntax
Kinds of Templates
Template Parameters: Type and Value
Template Parameters: this and alias
Template Parameters: Tuple
typeof Varieties
Template Specializations and Meta Programming
Compile-Time Polymorphism and Code Bloat
Template Constraints
Named Template Constraints
Using Templates in Multi-Dimensional Operator Overloading
Multi-Dimensional Operator Overloading Example
Summary
Quiz on Templates
More Functions
Return Type Attributes: auto and ref
Return Type Attributes: auto ref and inout
Behavioral Attributes: pure
Behavioral Attributes: nothrow and @nogc
Code Safety Attributes
Compile Time Function Execution (CTFE)
Summary
Quiz on Functions
Mixins
Template Mixins
String Mixins
Mixin Name Spaces
Mixins in Operator Overloading and Destructors
Importing Text Files
Example
Quiz on Mixins
Ranges
Introduction and History
Use of Ranges in D
Phobos Ranges
InputRange
Use of Slices as Ranges
Decoding of Strings as Ranges of dchar
Ranges Without Actual Elements
Infinite Ranges and Functions that Return Ranges
std.range and std.algorithm Modules
ForwardRange and BidirectionalRange
RandomAccessRange: Infinite
RandomAccessRange: Finite
OutputRange
Using Slices as OutputRange
Range Kind Templates
ElementType and Other Range Templates
Run-time Polymorphism with Ranges
Summary
Quiz on Ranges
static foreach and Parallelism
static foreach
Parallelism
taskPool.parallel()
Task
Exception Catching and Member Functions of Task
taskPool.asyncBuf()
taskPool.map() and taskPool.amap()
taskPool.reduce()
Tuple Results with Multiple functions and TaskPool
Summary
Quiz on static foreach and Parallelism
Message Passing Concurrency
Concepts
Starting Threads
Thread Identifiers
Message Passing
Message Passing: Example
Expecting Different Types of Messages
Exceptions During the Execution of the Worker
Detecting Thread Termination
Mailbox Management
Priority Messages and Thread Names
Summary
Quiz on Message Passing Concurrency
Data Sharing Concurrency
Sharing Data Between Threads
A Race Condition Example
Using synchronized to Avoid Race Conditions
static this() and Atomic Operations
Summary
Quiz on Data Sharing Concurrency
Fibers
Call Stack
Usage
Fibers in Range Implementations
Presenting Fibers as Ranges
Fibers in Asynchronous Input and Output
Exceptions and Fibers
Cooperative Multitasking
Summary
Quiz on Fibers
Memory Management
Memory
The Garbage Collector
Allocating Memory
Memory Block Attributes
Alignment: The .alignof Property
Alignment: The .offsetof Property
Constructing Variables at Specific Memory Locations
Construction and Destructions of Objects
Summary
Quiz on Memory Management
User Defined Attributes (UDA) and Operator Precedence
User-Defined Attributes (UDA)
UDA Example
The Benefit of UDA
Operator Precedence
Quiz on UDA and Operator Precedence
Conclusion
Wrap Up!
Advanced Programming Techniques in D
/
...
/
Summary
Summary
This lesson summarizes the concepts covered in this chapter.
We'll cover the following...
Chapter summary
Chapter summary
...