万本电子书0元读

万本电子书0元读

顶部广告

D Cookbook电子书

售       价:¥

1人正在读 | 0人评论 9.8

作       者:Adam D. Ruppe

出  版  社:Packt Publishing

出版时间:2014-05-26

字       数:223.6万

所属分类: 进口书 > 外文原版书 > 电脑/网络

温馨提示:数字商品不支持退换货,不提供源文件,不支持导出打印

为你推荐

  • 读书简介
  • 目录
  • 累计评论(0条)
  • 读书简介
  • 目录
  • 累计评论(0条)
A recipepacked reference guide filled with practical tasks that are concisely explained to develop and broaden the user's abilities with the D programming language. If you are an experienced programmer who is looking to explore a language that offers plenty of advantages over more established programming languages, this is the book for you. We assume that you are already familiar with general programming language basics, but you do not need to be a proficient user of D.
目录展开

D Cookbook

Table of Contents

D Cookbook

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. Core Tasks

Introduction

Installing the compiler and writing a "Hello World" program

How to do it…

How it works…

There's more…

Adding additional modules (files) to your program

How to do it…

How it works…

There's more…

See also

Using external libraries

How to do it…

How it works…

There's more…

See also

Building and processing arrays

How to do it…

How it works…

There's more…

See also

Using associative arrays to translate input

How to do it…

How it works…

There's more…

Creating a user-defined vector type

Getting ready

How to do it…

How it works…

See also

Using a custom exception type

How to do it…

How it works…

There's more…

See also

Understanding immutability

Getting ready

How to do it…

Writing functions

Writing object methods

How it works…

Slicing a string to get a substring

How to do it…

How it works…

There's more…

Creating a tree of classes

Getting ready

How to do it…

How it works…

There's more…

See also…

2. Phobos – The Standard Library

Introduction

Performing type conversions

How to do it…

How it works…

There's more…

Finding the largest files in a directory

How to do it…

How it works…

Creating a network client and server

How to do it…

Client

Server

How it works…

There's more…

See also

Using Base64 to create a data URI

How to do it…

How it works…

Generating random numbers

How to do it…

How it works…

There's more…

Normalizing a string and performing Unicode comparisons

How to do it…

How it works…

Searching with regular expressions

How to do it…

How it works…

There's more…

See also

Writing a digest utility

How to do it…

How it works…

There's more…

See also

Using the std.zlib compression

How to do it…

How it works…

Using the std.json module

How to do it…

How it works…

See also

3. Ranges

Introduction

Using ranges when implementing an algorithm

Getting ready

How to do it…

How it works…

Creating an input range

How to do it…

How it works…

There's more…

Creating an output range

How to do it…

How it works…

There's more…

See also

Creating a higher-order range

How to do it…

How it works…

Putting a range interface on a collection

Getting ready

How to do it…

How it works…

Creating an input range over a tree structure

Getting ready

How to do it…

How it works…

There's more…

Using runtime polymorphic (class) ranges

How to do it…

How it works…

Storing a range as a data member

How to do it…

How it works…

Sorting ranges efficiently

Getting ready

How to do it…

To sort

To benchmark

How it works…

See also

Searching ranges

How to do it…

How it works…

Using functional tools to query data

Getting ready

How to do it…

How it works…

There's more…

See also

4. Integration

Introduction

Calling the Windows API functions

Getting ready

How to do it…

How it works…

See also

Removing the Windows console

How to do it…

How it works…

There's more…

See also

Making Linux system calls

How to do it…

With the C interface

With inline assembly

How it works…

See also

Writing part of a C program in D

Getting ready

How to do it…

How it works…

See also

Interfacing with C++

Getting ready

How to do it …

How to do it…

See also

Using structs to mimic the C++ object structure

How to do it…

How it works…

Communicating with external processes

How to do it…

How it works…

See also

Communicating with a dynamic scripting language

Getting ready

How to do it…

How it works…

Using Windows' COM

Getting ready

How to do it…

COM server

COM client

How it works…

There's more…

5. Resource Management

Introduction

Avoiding the garbage collector

How to do it…

How it works…

Making a reference-counted object

How to do it…

How it works…

See also

Manually managing class memory

How to do it…

How it works…

See also

Using scope guards to manage transactions

How to do it…

How it works…

Creating an array replacement

How to do it…

How it works…

Managing lent resources

How to do it…

How it works…

Creating a NotNull struct

How to do it…

How it works…

There's more…

Using unique pointers

How to do it…

How it works…

Using RAII and handling the limitations of class destructors

How to do it…

How it works…

6. Wrapped Types

Introduction

Creating a struct with reference semantics

How to do it…

How it works…

There's more…

Simulating inheritance with structs

How to do it…

How it works…

Creating a ranged integer

How to do it…

How it works…

There's more…

Creating an opaque handle type

How to do it…

How it works…

There's more…

Creating a subtyped string for i18n

How to do it…

How it works…

Forwarding methods with opDispatch

How to do it…

How it works…

Creating a tagged dynamic type

How to do it…

How it works…

There's more…

Creating a structure with two views into the same data

How to do it…

How it works…

Simulating multiple inheritance with mixin templates

How to do it…

How it works…

7. Correctness Checking

Introduction

Using assertions and exceptions

How to do it…

How it works…

See also

Using static asserts

How to do it…

How it works…

Using template constraints and static if

Getting ready

How to do it…

How it works…

Preventing memory corruption bugs with @safe

How to do it…

How it works…

See also

Leveraging const-correctness

Getting ready

How to do it…

How it works…

Avoiding side effects of pure functions

How to do it…

How it works…

Verifying object invariants and pre- and post-conditions

How to do it…

How it works…

Unit testing your code

How to do it…

How it works…

See also

Documenting your code with Ddoc

How to do it…

How it works…

There's more…

Writing platform-specific code (versions) and per-client configuration modules

How to do it…

Platform-specific code

Client-specific code

How it works…

See also

8. Reflection

Introduction

Getting dynamic runtime type information

How to do it…

How it works…

See also

Getting a list of child classes

How to do it…

How it works…

Determining whether a module is available

How to do it…

How it works…

See also

Getting a list of all methods or fields in a module or an object

How to do it…

How it works…

There's more…

See also

Inspecting function overloads

How to do it…

How it works…

Determining names, types, and default values of function parameters

How to do it…

How it works…

There's more…

Getting components of complex types

Getting ready

How to do it…

How it works…

See also:

Using user-defined attributes

How to do it…

How it works…

Implementing a custom lint-style check for virtual functions

How to do it…

How it works…

Extending the runtime type information

How to do it…

How it works…

There's more…

Creating a command-line function caller

How to do it…

How it works…

There's more…

9. Code Generation

Introduction

Creating user-defined literals

Getting ready

How to do it…

How it works…

See also

Parsing a domain-specific language

How to do it…

How it works…

There's more…

See also

Generating data structures from text diagrams

How to do it…

How it works…

See also

Automating dynamic calls with multiple dispatch

Getting ready

How to do it…

How it works…

See also

Building a lookup table

How to do it…

How it works…

Using string parameters to change functions

How to do it…

How it works…

Wrapping instance methods

How to do it…

How it works…

See also

Using opDispatch to generate properties

How to do it…

How it works…

Duck typing to a statically-defined interface

Getting ready

How to do it…

How it works…

There's more…

10. Multitasking

Introduction

Using threads

How to do it…

How it works…

There's more…

See also

Passing messages with std.concurrency

How to do it…

How it works…

See also

Processing parallel data with std.parallelism

How to do it…

How it works…

See also

Using fibers

How to do it…

How it works…

See also

Creating new processes

How to do it…

How it works…

There's more…

See also

Exploring thread-safe, single-locking singletons

How to do it…

How it works…

See also

Using asynchronous I/O

How to do it…

How it works…

See also

11. D for Kernel Coding

Introduction

Running D on bare metal x86 with a stripped runtime

Getting ready

How to do it…

How it works…

There's more…

See also

Adding interrupt handling to the bare metal x86 code

Getting ready

How to do it…

How it works…

12. Web and GUI Programming

Introduction

Creating a dynamic website with cgi.d

Getting ready

How to do it…

How it works…

See also

Creating a web API with web.d

Getting ready

How to do it…

How it works…

There's more…

Parsing and modifying an HTML page with dom.d

Getting ready

How to do it…

How it works…

There's more…

See also

Accessing a SQL database

Getting ready

How to do it…

How it works…

There's more…

See also

Sending an e-mail

Getting ready

How to do it…

How it works…

There's more…

Writing colored output to the console

Getting ready

How to do it…

How it works…

See also

Getting real-time input from the terminal

Getting ready

How to do it…

How it works…

There's more…

See also

Working with image files

Getting ready

How to do it…

How it works…

See also

Creating a graphics window to show a TV static demo

Getting ready

How to do it…

How it works…

See also

Creating an OpenGL window

Getting ready

How to do it…

How it works…

See also

A. Addendum

Compiling D for ARM/Linux Raspberry Pi

Getting ready

How to do it…

How it works…

There's more…

See also

Running D on bare metal ARM

Getting ready

How to do it…

How it works…

See also

Using the exponentiation operator

How to do it…

How it works…

Getting a stack trace without throwing an exception

How to do it…

How it works…

Finding more information about D

How to do it…

How it works…

Index

累计评论(0条) 10个书友正在讨论这本书 发表评论

发表评论

发表评论,分享你的想法吧!

买过这本书的人还买过

读了这本书的人还在读

回顶部