logo资料库

The Dart Programming Language.pdf

第1页 / 共787页
第2页 / 共787页
第3页 / 共787页
第4页 / 共787页
第5页 / 共787页
第6页 / 共787页
第7页 / 共787页
第8页 / 共787页
资料共787页,剩余部分请下载后查看
About This E-Book
Title Page
Copyright Page
Dedication Page
Contents
Foreword
Preface
Acknowledgments
About the Author
Chapter 1. Introduction
1.1 Motivation
1.2 Design Principles
1.2.1 Everything Is an Object
1.2.2 Program to an Interface, not an Implementation
1.2.3 Types in the Service of the Programmer
1.3 Constraints
1.4 Overview
1.5 Book Structure
1.6 Related Work and Influences
Chapter 2. Objects, Interfaces, Classes and Mixins
2.1 Accessors
2.2 Instance Variables
2.3 Class Variables
2.4 Finals
2.5 Identity and Equality
2.6 Class and Superclass
2.7 Abstract Methods and Classes
2.8 Interfaces
2.9 Life of an Object
2.9.1 Redirecting Constructors
2.9.2 Factories
2.10 noSuchMethod()
2.11 Constant Objects and Fields
2.12 Class Methods
2.13 Instances, Their Classes and Metaclasses
2.14 Object and Its Methods
2.15 Mixins
2.15.1 Example: The Expression Problem
2.16 Related Work
2.17 Summary
Chapter 3. Libraries
3.1 The Top Level
3.2 Scripts
3.3 Privacy
3.4 Imports
3.5 Breaking Libraries into Parts
3.6 Exports
3.7 Diamond Imports
3.8 Deferred Loading
3.9 Related Work
3.10 Summary
Chapter 4. Functions
4.1 Parameters
4.1.1 Positional Parameters
4.1.2 Named Parameters
4.2 Function Bodies
4.3 Function Declarations
4.4 Closures
4.5 Invoking Methods and Functions
4.5.1 Cascades
4.5.2 Assignment
4.5.3 Using Operators
4.6 The Function Class
4.6.1 Emulating Functions
4.7 Functions as Objects
4.8 Generator Functions
4.8.1 Iterators and Iterables
4.8.2 Synchronous Generators
4.9 Related Work
4.10 Summary
Chapter 5. Types
5.1 Optional Typing
5.2 A Tour of Types
5.3 Interface Types
5.4 Types in Action: The Expression Problem, Typed
5.5 Generics
5.5.1 The Expression Problem with Generics
5.6 Function Types
5.6.1 Optional Positional Parameters
5.6.2 Named Parameters
5.6.3 Call() Revisited
5.7 Type Reification
5.7.1 Type Tests
5.7.2 Type Casts
5.7.3 Checked Mode
5.7.4 Reified Generics
5.7.5 Reification and Optional Typing
5.7.6 Types and Proxies
5.8 Malformed Types
5.9 Unsoundness
5.10 Related Work
5.11 Summary
Chapter 6. Expressions and Statements
6.1 Expressions
6.1.1 Literals
6.1.2 Identifiers
6.1.3 this
6.1.4 Constants
6.1.5 Creating Objects
6.1.6 Assignment
6.1.7 Extracting Properties
6.1.8 Method Access
6.1.9 Using Operators
6.1.10 Throw
6.1.11 Conditionals
6.2 Statements
6.2.1 Blocks
6.2.2 If
6.2.3 Loops
6.2.4 Try-Catch
6.2.5 Rethrow
6.2.6 Switch
6.2.7 Assert
6.2.8 Return
6.2.9 Yield and Yield-Each
6.2.10 Labels
6.2.11 Break and Continue
6.3 Summary
Chapter 7. Reflection
7.1 Introspection
7.1.1 Implications for Speed and Size
7.1.2 Example: Proxies
7.1.3 Example: Serialization
7.1.4 Example: Parser Combinators
7.2 Why Mirrors
7.3 Metadata
7.4 Reflection via Code Generation
7.5 Beyond Introspection
7.6 Related Work
7.7 Summary
Chapter 8. Asynchrony and Isolates
8.1 Asynchrony
8.2 Futures
8.2.1 Consuming Futures
8.2.2 Producing Futures
8.2.3 Scheduling
8.3 Streams
8.4 Isolates
8.4.1 Ports
8.4.2 Spawning
8.4.3 Security
8.5 Example: Client-Server Communication
8.5.1 Promise: A Brighter Future
8.5.2 Isolates as Distributed Objects
8.6 Asynchronous Functions
8.6.1 Await
8.6.2 Asynchronous Generators
8.6.3 Await-For loops
8.7 Related Work
8.8 Summary
Chapter 9. Conclusion
9.1 Optional Typing
9.2 Object Orientation
9.3 Reflection
9.4 Tooling
9.5 Summary
Bibliography
Index
Code Snippets
About This E-Book EPUB is an open, industry-standard format for e-books. However, support for EPUB and its many features varies across reading devices and applications. Use your device or app settings to customize the presentation to your liking. Settings that you can customize often include font, font size, single or double column, landscape or portrait mode, and figures that you can click or tap to enlarge. For additional information about the settings and features on your reading device or app, visit the device manufacturer’s Web site. Many titles include programming code or configuration examples. To optimize the presentation of these elements, view the e-book in single-column, landscape mode and adjust the font size to the smallest setting. In addition to presenting code and configurations in the reflowable text format, we have included images of the code that mimic the presentation found in the print book; therefore, where the reflowable format may compromise the presentation of the code listing, you will see a “Click here to view code image” link. Click the link to view the print-fidelity code image. To return to the previous page viewed, click the Back button on your device or app.
The Dart Programming Language Gilad Bracha Boston • Columbus • Indianapolis • New York • San Francisco • Amsterdam • Cape Town Dubai • London • Madrid • Milan • Munich • Paris • Montreal • Toronto • Delhi • Mexico Sao Paulo • Sidney • Hong Kong • Seoul • Singapore • Taipei • Tokyo City
Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in this book, and the publisher was aware of a trademark claim, the designations have been printed with initial capital letters or in all capitals. The author and publisher have taken care in the preparation of this book, but make no expressed or implied warranty of any kind and assume no responsibility for errors or omissions. No liability is assumed for incidental or consequential damages in connection with or arising out of the use of the information or programs contained herein. For information about buying this title in bulk quantities, or for special sales opportunities (which may include electronic versions; custom cover designs; and content particular to your business, training goals, marketing focus, or branding interests), please contact our corporate sales department at corpsales@pearsoned.com or (800) 382-3419. For government sales inquiries, please contact governmentsales@pearsoned.com. For questions about sales outside the United States, please contact international@pearsoned.com. Visit us on the Web: informit.com/aw Library of Congress Control Number: 2015953614 Copyright © 2016 Pearson Education, Inc. All rights reserved. Printed in the United States of America. This publication is protected by copyright, and permission must be obtained from the publisher prior to any prohibited reproduction, storage in a retrieval system, or transmission in any form or by any means, electronic, mechanical, photocopying, recording, or likewise. For information regarding permissions, request forms and the appropriate contacts within the Pearson Education Global Rights & Permissions Department, please visit www.pearsoned.com/permissions/. ISBN-13: 978-0-321-92770-5 ISBN-10: 0-321-92770-2 Text printed in the United States on recycled paper at RR Donnelley in Crawfordsville, Indiana. First printing, December 2015
To my mother, Shoshana, who taught me to be picky.
Contents Foreword Preface Acknowledgments About the Author Chapter 1 Introduction 1.1 Motivation 1.2 Design Principles 1.2.1 Everything Is an Object 1.2.2 Program to an Interface, not an Implementation 1.2.3 Types in the Service of the Programmer 1.3 Constraints 1.4 Overview 1.5 Book Structure 1.6 Related Work and Influences Chapter 2 Objects, Interfaces, Classes and Mixins 2.1 Accessors 2.2 Instance Variables 2.3 Class Variables 2.4 Finals 2.5 Identity and Equality 2.6 Class and Superclass 2.7 Abstract Methods and Classes 2.8 Interfaces 2.9 Life of an Object 2.9.1 Redirecting Constructors 2.9.2 Factories 2.10 noSuchMethod() 2.11 Constant Objects and Fields 2.12 Class Methods 2.13 Instances, Their Classes and Metaclasses
2.14 Object and Its Methods 2.15 Mixins 2.15.1 Example: The Expression Problem 2.16 Related Work 2.17 Summary Chapter 3 Libraries 3.1 The Top Level 3.2 Scripts 3.3 Privacy 3.4 Imports 3.5 Breaking Libraries into Parts 3.6 Exports 3.7 Diamond Imports 3.8 Deferred Loading 3.9 Related Work 3.10 Summary Chapter 4 Functions 4.1 Parameters 4.1.1 Positional Parameters 4.1.2 Named Parameters 4.2 Function Bodies 4.3 Function Declarations 4.4 Closures 4.5 Invoking Methods and Functions 4.5.1 Cascades 4.5.2 Assignment 4.5.3 Using Operators 4.6 The Function Class 4.6.1 Emulating Functions 4.7 Functions as Objects 4.8 Generator Functions 4.8.1 Iterators and Iterables
4.8.2 Synchronous Generators 4.9 Related Work 4.10 Summary Chapter 5 Types 5.1 Optional Typing 5.2 A Tour of Types 5.3 Interface Types 5.4 Types in Action: The Expression Problem, Typed 5.5 Generics 5.5.1 The Expression Problem with Generics 5.6 Function Types 5.6.1 Optional Positional Parameters 5.6.2 Named Parameters 5.6.3 Call() Revisited 5.7 Type Reification 5.7.1 Type Tests 5.7.2 Type Casts 5.7.3 Checked Mode 5.7.4 Reified Generics 5.7.5 Reification and Optional Typing 5.7.6 Types and Proxies 5.8 Malformed Types 5.9 Unsoundness 5.10 Related Work 5.11 Summary Chapter 6 Expressions and Statements 6.1 Expressions 6.1.1 Literals 6.1.2 Identifiers 6.1.3 this 6.1.4 Constants 6.1.5 Creating Objects
分享到:
收藏