ebook img

Types and Programming Languages PDF

645 Pages·2002·1.74 MB·english
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview Types and Programming Languages

Types and Programming Languages Types and Programming Languages Benjamin C. Pierce TheMITPress Cambridge,Massachusetts London,England ©2002BenjaminC.Pierce All rights reserved. No part of this book may be reproduced in any form by any electronic of mechanical means (including photocopying, recording, or information storage and retrieval) without permission in writing from the publisher. This book was set in Lucida Bright by the author using the LATEX document preparationsystem. PrintedandboundintheUnitedStatesofAmerica. LibraryofCongressCataloging-in-PublicationData Pierce,BenjaminC. Typesandprogramminglanguages/BenjaminC.Pierce p. cm. Includesbibliographicalreferencesandindex. ISBN0-262-16209-1(hc.:alk.paper) 1.Programminglanguages(Electroniccomputers). I.Title. QA76.7.P54 2002 005.13—dc21 2001044428 Contents Preface xiii 1 Introduction 1 1.1 TypesinComputerScience 1 1.2 WhatTypeSystemsAreGoodFor 4 1.3 TypeSystemsandLanguageDesign 9 1.4 CapsuleHistory 10 1.5 RelatedReading 12 2 MathematicalPreliminaries 15 2.1 Sets,Relations,andFunctions 15 2.2 OrderedSets 16 2.3 Sequences 18 2.4 Induction 19 2.5 BackgroundReading 20 I Untyped Systems 21 3 UntypedArithmeticExpressions 23 3.1 Introduction 23 3.2 Syntax 26 3.3 InductiononTerms 29 3.4 SemanticStyles 32 3.5 Evaluation 34 3.6 Notes 43 vi Contents 4 AnMLImplementationofArithmeticExpressions 45 4.1 Syntax 46 4.2 Evaluation 47 4.3 TheRestoftheStory 49 5 TheUntypedLambda-Calculus 51 5.1 Basics 52 5.2 ProgrammingintheLambda-Calculus 58 5.3 Formalities 68 5.4 Notes 73 6 NamelessRepresentationofTerms 75 6.1 TermsandContexts 76 6.2 ShiftingandSubstitution 78 6.3 Evaluation 80 7 AnMLImplementationoftheLambda-Calculus 83 7.1 TermsandContexts 83 7.2 ShiftingandSubstitution 85 7.3 Evaluation 87 7.4 Notes 88 II Simple Types 89 8 TypedArithmeticExpressions 91 8.1 Types 91 8.2 TheTypingRelation 92 8.3 Safety=Progress+Preservation 95 9 SimplyTypedLambda-Calculus 99 9.1 FunctionTypes 99 9.2 TheTypingRelation 100 9.3 PropertiesofTyping 104 9.4 TheCurry-HowardCorrespondence 108 9.5 ErasureandTypability 109 9.6 Curry-Stylevs.Church-Style 111 9.7 Notes 111 10 AnMLImplementationofSimpleTypes 113 10.1 Contexts 113 10.2 TermsandTypes 115 10.3 Typechecking 115 Contents vii 11 SimpleExtensions 117 11.1 BaseTypes 117 11.2 TheUnitType 118 11.3 DerivedForms:SequencingandWildcards 119 11.4 Ascription 121 11.5 LetBindings 124 11.6 Pairs 126 11.7 Tuples 128 11.8 Records 129 11.9 Sums 132 11.10 Variants 136 11.11 GeneralRecursion 142 11.12 Lists 146 12 Normalization 149 12.1 NormalizationforSimpleTypes 149 12.2 Notes 152 13 References 153 13.1 Introduction 153 13.2 Typing 159 13.3 Evaluation 159 13.4 StoreTypings 162 13.5 Safety 165 13.6 Notes 170 14 Exceptions 171 14.1 RaisingExceptions 172 14.2 HandlingExceptions 173 14.3 ExceptionsCarryingValues 175 III Subtyping 179 15 Subtyping 181 15.1 Subsumption 181 15.2 TheSubtypeRelation 182 15.3 PropertiesofSubtypingandTyping 188 15.4 TheTopandBottomTypes 191 15.5 SubtypingandOtherFeatures 193 15.6 CoercionSemanticsforSubtyping 200 15.7 IntersectionandUnionTypes 206 15.8 Notes 207 viii Contents 16 MetatheoryofSubtyping 209 16.1 AlgorithmicSubtyping 210 16.2 AlgorithmicTyping 213 16.3 JoinsandMeets 218 16.4 AlgorithmicTypingandtheBottomType 220 17 AnMLImplementationofSubtyping 221 17.1 Syntax 221 17.2 Subtyping 221 17.3 Typing 222 18 CaseStudy:ImperativeObjects 225 18.1 WhatIsObject-OrientedProgramming? 225 18.2 Objects 228 18.3 ObjectGenerators 229 18.4 Subtyping 229 18.5 GroupingInstanceVariables 230 18.6 SimpleClasses 231 18.7 AddingInstanceVariables 233 18.8 CallingSuperclassMethods 234 18.9 ClasseswithSelf 234 18.10 OpenRecursionthroughSelf 235 18.11 OpenRecursionandEvaluationOrder 237 18.12 AMoreEfficientImplementation 241 18.13 Recap 244 18.14 Notes 245 19 CaseStudy:FeatherweightJava 247 19.1 Introduction 247 19.2 Overview 249 19.3 NominalandStructuralTypeSystems 251 19.4 Definitions 254 19.5 Properties 261 19.6 Encodingsvs.PrimitiveObjects 262 19.7 Notes 263

See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.