You are previewing Learn to Tango with D.
O'Reilly logo
Learn to Tango with D

Book Description

In recent years, much work has been put into creating programming languages that embody a blend of many of the most admired characteristics of their predecessors. One such language is D, which provides developers with the speed of languages such as C and C++ combined with the power and flexibility of languages such as Ruby and Python.

Learn to Tango with D introduces you to the powerful D language, with special attention given to the Tango software library. A concise yet thorough overview of the language's syntax and features is presented, followed by an introduction to Tango, the popular general-purpose library you'll find invaluable when building your D applications.

Table of Contents

  1. Foreword
  2. About the Authors
  3. About the Technical Reviewer
  4. Acknowledgments
  5. 1. First Steps
    1. Hello World
    2. Source Modules
    3. Package, Import, and Symbol Visibility
    4. Installation
    5. Compilation Tools
  6. 2. D Fundamentals
    1. Declarations
      1. Declaration Syntax and Variable Initialization
      2. Declarations and Scope
    2. Basic Types
      1. Properties
      2. Integral Types
      3. Floating-Point Types
      4. Character Types
    3. Pointers
    4. Arrays
      1. Static Arrays
      2. Dynamic Arrays
      3. Strings
      4. Associative Arrays
      5. Array Operations
        1. Slicing
        2. Copying
        3. Concatenation
    5. Flow Control
      1. Conditionals
        1. if-else Blocks
        2. The Ternary Operator
        3. switch-case Statements
      2. Looping Constructs
        1. for Loops
        2. while Loops
        3. foreach Loops
      3. The goto Statement
    6. Functions
    7. Error Handling
      1. Throwing Exceptions
      2. Catching Exceptions
      3. Using a scope Statement
  7. 3. D's Object-Oriented Features
    1. Modules
      1. Naming Modules
      2. Importing Other Modules
        1. Basic Imports
        2. Renamed Imports
        3. Selective Imports
        4. Static Imports
      3. Accessing Variables in Module Scope
      4. Creating Unit Tests
    2. Structs and Unions
      1. Defining Structs
      2. Defining Unions
      3. Initializing Structs
        1. Static Initialization
        2. Dynamic Initialization
        3. Struct Literals
        4. Struct Allocation
      4. Using Struct Properties
    3. Classes
      1. Class Definition and Instantiation
      2. Invariants
      3. Inheritance
      4. Polymorphism
        1. Protection Attributes
        2. Overloading Methods
        3. Overriding Methods
        4. Covariant Return Types
        5. Final Methods
        6. Static Members
        7. Constructors and Destructors
      5. Nested Classes
      6. Anonymous Classes
      7. Class Properties
    4. Interfaces
      1. Interface Definition
      2. Class Implementation of Interfaces
      3. Abstract Classes
    5. Operator Overloading
      1. Unary Operators
      2. Binary Operators
      3. Special Operators
  8. 4. Procedural Lifetime
    1. D Language Type Classifications
    2. Scope and Lifetime
    3. Storage Classes
      1. Auto Storage Class
      2. Static Storage Class
    4. Static Constructors
    5. Lifetime Characteristics of Modules
      1. Static Initialization Order
      2. Module Initialization Order
      3. Module Lifetime States
    6. Lifetime Characteristics of Functions
      1. Lifetime of Arrays
        1. Static Arrays
        2. Dynamic Arrays
      2. Lifetime of Delegates
      3. Lazy Expressions
    7. Garbage Collection
  9. 5. Templates
    1. The Problem of Insufficient Information
    2. Type Templates
    3. Function Templates
    4. Template Specialization
    5. Template Metaprogramming
      1. Template Value Parameters
      2. Boolean Logic
        1. if/else Templates
        2. static if Statements
        3. is Expressions
      3. Looping
    6. Compile-Time Function Evaluation
  10. 6. Text Processing
    1. String-Manipulation Utilities
      1. String-Modifying Operations
      2. String-Searching Operations
      3. String-Splitting Operations
      4. Stream-Splitting Operations
    2. Text Class
      1. Read-Only View Methods
      2. Modifying Methods
        1. Selecting a Part of the Text
        2. Operating on a Selection
        3. Performing Nonselection Operations
      3. Text Combined with the Utilities
    3. Numeric Conversion
      1. Formatting a Value into a String
      2. Converting Strings into Numeric Types
      3. Converting Integers
      4. Converting Floating-Point Numbers
      5. Converting Dates
    4. Layout and Formatting
      1. The Format String
        1. Alignment Component
        2. Format String Component
      2. The Layout Class
      3. Locale Support
  11. 7. Input and Output
    1. Console I/O
      1. Console Output Using Cout and Cerr
      2. Console Input with Cin
      3. Formatted Output Using Stdout and Stderr
    2. Stream I/O
      1. Streaming Files
      2. A Fistful of Streams
      3. Streams of Memory
      4. Stream Iterators
    3. Network I/O
      1. Creating an InternetAddress
      2. Low-Level Socket Access
      3. Using TCP/IP Streams with SocketConduit
      4. Packet Operations with DatagramConduit
      5. Simple Publish/Subscribe Using MulticastSocket
      6. Writing a TCP/IP Server with ServerSocket
    4. File Handling
      1. Accessing File Content Using FileConduit
      2. Reading and Writing a Complete File
      3. Working with UnicodeFile
      4. Using Additional FileSystem Controls
      5. Working with FileRoots
      6. Listing Files and Folders Using FileScan
      7. Manipulating Paths Using FilePath
  12. 8. The Other Packages
    1. The Package Rundown
      1. tango.core
      2. tango.math
      3. tango.stdc
      4. tango.sys
      5. tango.util
    2. Threads and Fibers
      1. Threads
      2. Fibers
    3. Collections
      1. Bags
      2. Sets
      3. Sequences
      4. Maps
      5. More on Collections
    4. Logging
      1. Loggers
      2. Log Levels
      3. More on Logging
    5. And That's Not All!