售 价:¥
温馨提示:数字商品不支持退换货,不提供源文件,不支持导出打印
为你推荐
Learning D
Table of Contents
Learning D
Credits
Foreword
About the Author
About the Reviewers
www.PacktPub.com
Support files, eBooks, discount offers, and more
Why subscribe?
Free access for Packt account holders
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Errata
Piracy
Questions
1. How to Get a D in Programming
Say hello to D
An introductory program
Getting help
The Digital Mars D compiler
Frontends, backends, and linkers
Installing DMD
The Windows installer
Installing from the ZIP
The Windows ZIP
The POSIX ZIPs
Compiling the example
Documentation and source code
The documentation
The source
Say hello to MovieMan
The problem
The features
DUB – the D build tool and package manager
Getting started
Configuring the MovieMan project
Understanding dub.sdl
Building and running MovieMan
Changing the output directory
Summary
2. Building a Foundation with D Fundamentals
The very basics
Identifiers
A note about scope
More on modules
Module declarations
More about import declarations
The special package module
Comments
Variable declaration and initialization
Basic types
The types
Literals
Integer literals
Floating-point literals
Character literals
Conversions
Alias declarations
Properties
Basic operators
Arithmetic operators
Bitwise operators
Relational and logical operators
The cast operator
Derived data types
Pointers
Arrays
Array basics
Rectangular arrays
Slices
Array literals
Arrays and void
Array operations
Strings
String essentials
Alternative string literals
WYSIWYG strings
Delimited strings
Token strings
Associative arrays
Control flow statements
Traditional loops
The foreach loop
Traditional conditionals
The goto statement
Type qualifiers – const and immutable
The contracts
With the basic types
With pointers
With arrays
Conversions
Functions
Overloaded functions
ref and out
inout parameters
lazy parameters
Function attributes
Return statements and memory
Function pointers and delegates
MovieMan – first steps
The io module
The app module
Summary
3. Programming Objects the D Way
User-defined types
Enumerations
Unions
Structs and classes
Working with objects
Encapsulation with protection attributes
Public
Private
Package
Voldemort types
Constructors and destructors
Class constructors and destructors
Struct constructors and destructors
Static constructors and destructors
Inheritance and polymorphism
Interfaces
Fake inheritance
Nested classes
Objects with const and immutable
const as a storage class
Error handling
Scope guards
Exception handling
Contract programming and unit tests
Assert contracts
Function contracts
Invariants
Unit tests
MovieMan – adding menus
The Menu base class
The MainMenu class
The DisplayMenu class
Summary
4. Running Code at Compile Time
Pragmas
The lib pragma
The msg pragma
The inline pragma
Conditional compilation
The version condition
The debug condition
The static if condition
Compile-time strings
The import expression
String mixins
Compile-time function execution
Odds and ends
static assert
The is expression
Alignment
Compile-time reflection
User-defined attributes
Summary
5. Generic Programming Made Easy
Template basics
Templates as code blocks
Struct and class templates
Enum templates
Function templates
Special features
More template parameters
Value parameters
Alias parameters
This parameters
Beyond the basics
Template specializations
Specialization on pointers and arrays
Template constraints
Template mixins
Variadic templates
Terminology
More on usage
Operator overloading
Non-templated operator overloads
Comparison overloads – opEquals and opCmp
opEquals
opCmp
Considerations
Function call overloads
Assignment overloads
Index overloads
opIndex
opIndexAssign
opDollar
Templated operator overloads
Unary overloads
Binary overloads
Cast overloads
Operator assignment overloads
Slice operator overloads
Other overloads
opDispatch
opApply
toHash
MovieMan – the database
db.d
Back to the menus
Summary
6. Understanding Ranges
Ranges defined
The problem
The solution
The interface
A range for arrays
The implementation of filter
The test
The real ranges
Input ranges
Forward ranges
Bidirectional ranges
Random-access ranges
Output ranges
Optional range primitives
hasLength
isInfinite
Other options
Ranges in use
Custom ranges
Getting a range from a stack
A name generator range
Other considerations
Custom algorithms
Summary
7. Composing Functional Pipelines with Algorithms and Ranges
Functional programming and composable pipelines
A simple example
A more complex example
Sometimes we can't
Navigating Phobos
std.range
Generative ranges
iota
recurrence
sequence
Selective ranges
take
drop
stride
retro
Compositional ranges
chain
roundRobin
transposed
zip
lockstep
std.algorithm
Comparison
equal
cmp
mismatch
levenshteinDistance
Iteration
group
map
reduce
Mutation
copy
fill
remove
Searching
find
count
any
Set operations
setIntersection
setDifference
setUnion
Sorting
sort
partition
std.array
Appender
assocArray
join
Where to look for more
MovieMan – wrapping up
The db module
The display menu
Making it better
Summary
8. Exploring the Wide World of D
Online resources
DWiki
Planet D
reddit and StackOverflow
This Week in D
DConf
DSource
Editors and IDEs
Text editors
Vim and Emacs
Textadept
Sublime Text
IDEs
Visual D
Mono-D
DDT
Code::Blocks
Tools and utilities
DMD
Optimized and debug builds
Changing the default output
Compiling libraries
Using libraries
Warnings
Profiling
Code coverage analysis
Compile and run
GDC and LDC
GDC
LDC
RDMD
DustMite
DCD
DVM
Libraries
code.dlang.org
Using libraries from the DUB registry
Registering libraries with the DUB registry
Browsing the DUB registry
Deimos and DerelictOrg
Summary
9. Connecting D with C
Preliminaries
Terminology
Bindings, wrappers, and ports
Dynamic and static – context matters
Static libraries and static linking
Dynamic libraries and dynamic linking
Dynamic and static bindings
Object file formats
Linkage attributes
Name mangling
Calling conventions
Putting it together
Binding D to C
Function prototypes
Manually loading shared libraries
Trying it out
C types to D types
Strings and characters
Special types
Enumerations
Structures
Pointers
Type aliases
Function pointers
Defined constants
Function parameters and return types
Symbols
Global variables
Macros
Conditional compilation
Calling C from D
D arrays and C arrays
Basic arrays
Arrays of arrays
Strings
Memory
C callbacks and exceptions
Calling D from C
Summary
10. Taking D Online
The software
vibe.d
Package overview
The anatomy of a vibe.d web app
The database library
MovieManWeb
Getting started
The basics of diet templates
Tags and indentation
Including and extending templates
The MovieManWeb layout
Setting up the database
Fleshing out the index page
Mapping web interface functions to URLs
Rendering diet templates
Rewriting index.dt
Adding movies
Implementing the addMovie function
Implementing the postAdd function
Implementing add.dt
Modifying index.dt
Modifying app.d
Modifying layout.dt
Listing movies
Implementing the listMovies function
Modifying the index function
Modifying index.dt
Finding movies
Implementing the postFind function
Implementing find.dt
Modifying index.dt
Modifying app.d and layout.dt
Implementing the findMovie functions
findMovie the first
findMovie the second
Editing and deleting movies
Expanding on MovieManWeb
Summary
11. Taking D to the Next Level
Concurrency
Threads and fibers
Threads
Fibers
Data sharing
__gshared
Shared
Synchronization and atomics
Automatic synchronization
Manual synchronization
Atomics
Message passing
Parallelism
More information
SafeD
Functional purity
The garbage collector
Connecting with C++
More on Phobos
std.container
std.datetime
std.digest
std.experimental
std.getopt
std.process
std.socket
Modules for Unicode and other encodings
System bindings
Game development with D
The future of D
Summary
Index
买过这本书的人还买过
读了这本书的人还在读
同类图书排行榜