ebook img

Programming Language Design Concepts PDF

492 Pages·2004·1.901 MB·
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 Programming Language Design Concepts

PROGRAMMING LANGUAGE DESIGN CONCEPTS PROGRAMMING LANGUAGE DESIGN CONCEPTS David A. Watt, University of Glasgow with contributions by William Findlay, University of Glasgow Copyright2004 JohnWiley&SonsLtd,TheAtrium,SouthernGate,Chichester, WestSussexPO198SQ,England Telephone(+44)1243779777 Email(forordersandcustomerserviceenquiries):[email protected] VisitourHomePageonwww.wileyeurope.comorwww.wiley.com AllRightsReserved.Nopartofthispublicationmaybereproduced,storedinaretrievalsystemortransmittedin anyformorbyanymeans,electronic,mechanical,photocopying,recording,scanningorotherwise,exceptunder thetermsoftheCopyright,DesignsandPatentsAct1988orunderthetermsofalicenceissuedbytheCopyright LicensingAgencyLtd,90TottenhamCourtRoad,LondonW1T4LP,UK,withoutthepermissioninwritingofthe Publisher,withtheexceptionofanymaterialsuppliedspecificallyforthepurposeofbeingenteredandexecuted onacomputersystemforexclusiveusebythepurchaseofthepublication.RequeststothePublishershouldbe addressedtothePermissionsDepartment,JohnWiley&SonsLtd,TheAtrium,SouthernGate,Chichester,West SussexPO198SQ,England,[email protected],orfaxedto(+44)1243770620. Thispublicationisdesignedtoprovideaccurateandauthoritativeinformationinregardtothesubjectmatter covered.ItissoldontheunderstandingthatthePublisherisnotengagedinrenderingprofessionalservices.If professionaladviceorotherexpertassistanceisrequired,theservicesofacompetentprofessionalshouldbesought. ADAisaregisteredtrademarkoftheUSGovernmentAdaJointProgramOffice. JAVAisaregisteredtrademarkofSunMicrosystemsInc. OCCAMisaregisteredtrademarkoftheINMOSGroupofCompanies. UNIXisaregisteredtrademarkofAT&TBellLaboratories. OtherWileyEditorialOffices JohnWiley&SonsInc.,111RiverStreet,Hoboken,NJ07030,USA Jossey-Bass,989MarketStreet,SanFrancisco,CA94103-1741,USA Wiley-VCHVerlagGmbH,Boschstr.12,D-69469Weinheim,Germany JohnWiley&SonsAustraliaLtd,33ParkRoad,Milton,Queensland4064,Australia JohnWiley&Sons(Asia)PteLtd,2ClementiLoop#02-01,JinXingDistripark,Singapore129809 JohnWiley&SonsCanadaLtd,22WorcesterRoad,Etobicoke,Ontario,CanadaM9W1L1 Wileyalsopublishesitsbooksinavarietyofelectronicformats.Somecontentthatappears inprintmaynotbeavailableinelectronicbooks. LibraryofCongressCataloging-in-PublicationData Watt,DavidA.(DavidAnthony) Programminglanguagedesignconcepts/DavidA.Watt;with contributionsbyWilliamFindlay. p.cm. Includesbibliographicalreferencesandindex. ISBN0-470-85320-4(pbk.:alk.paper) 1.Programminglanguages(Electroniccomputers)I.Findlay,William, 1947-II.Title. QA76.7.W3882004 005.13–dc22 2003026236 BritishLibraryCataloguinginPublicationData AcataloguerecordforthisbookisavailablefromtheBritishLibrary ISBN0-470-85320-4 Typesetin10/12ptTimesTenbyLaserwordsPrivateLimited,Chennai,India PrintedandboundinGreatBritainbyBiddlesLtd,King’sLynn Thisbookisprintedonacid-freepaperresponsiblymanufacturedfromsustainableforestry inwhichatleasttwotreesareplantedforeachoneusedforpaperproduction. To Carol Contents Preface xv Part I: Introduction 1 1 Programminglanguages 3 1.1 Programminglinguistics 3 1.1.1 Conceptsandparadigms 3 1.1.2 Syntax,semantics,andpragmatics 5 1.1.3 Languageprocessors 6 1.2 Historicaldevelopment 6 Summary 10 Furtherreading 10 Exercises 10 Part II: Basic Concepts 13 2 Valuesandtypes 15 2.1 Types 15 2.2 Primitivetypes 16 2.2.1 Built-inprimitivetypes 16 2.2.2 Definedprimitivetypes 18 2.2.3 Discreteprimitivetypes 19 2.3 Compositetypes 20 2.3.1 Cartesianproducts,structures,andrecords 21 2.3.2 Mappings,arrays,andfunctions 23 2.3.3 Disjointunions,discriminatedrecords,andobjects 27 2.4 Recursivetypes 33 2.4.1 Lists 33 2.4.2 Strings 35 2.4.3 Recursivetypesingeneral 36 2.5 Typesystems 37 2.5.1 Staticvsdynamictyping 38 2.5.2 Typeequivalence 40 2.5.3 TheTypeCompletenessPrinciple 42 2.6 Expressions 43 2.6.1 Literals 43 2.6.2 Constructions 44 2.6.3 Functioncalls 46 2.6.4 Conditionalexpressions 47 2.6.5 Iterativeexpressions 48 2.6.6 Constantandvariableaccesses 49 vii viii Contents 2.7 Implementationnotes 49 2.7.1 Representationofprimitivetypes 49 2.7.2 RepresentationofCartesianproducts 50 2.7.3 Representationofarrays 50 2.7.4 Representationofdisjointunions 51 2.7.5 Representationofrecursivetypes 51 Summary 52 Furtherreading 52 Exercises 52 3 Variablesandstorage 57 3.1 Variablesandstorage 57 3.2 Simplevariables 58 3.3 Compositevariables 59 3.3.1 Totalvsselectiveupdate 60 3.3.2 Staticvsdynamicvsflexiblearrays 61 3.4 Copysemanticsvsreferencesemantics 63 3.5 Lifetime 66 3.5.1 Globalandlocalvariables 66 3.5.2 Heapvariables 68 3.5.3 Persistentvariables 71 3.6 Pointers 73 3.6.1 Pointersandrecursivetypes 74 3.6.2 Danglingpointers 75 3.7 Commands 77 3.7.1 Skips 77 3.7.2 Assignments 77 3.7.3 Properprocedurecalls 78 3.7.4 Sequentialcommands 79 3.7.5 Collateralcommands 79 3.7.6 Conditionalcommands 80 3.7.7 Iterativecommands 82 3.8 Expressionswithsideeffects 85 3.8.1 Commandexpressions 86 3.8.2 Expression-orientedlanguages 87 3.9 Implementationnotes 87 3.9.1 Storageforglobalandlocalvariables 88 3.9.2 Storageforheapvariables 89 3.9.3 Representationofdynamicandflexiblearrays 90 Summary 91 Furtherreading 91 Exercises 92 4 Bindingsandscope 95 4.1 Bindingsandenvironments 95 4.2 Scope 97 Contents ix 4.2.1 Blockstructure 97 4.2.2 Scopeandvisibility 99 4.2.3 Staticvsdynamicscoping 100 4.3 Declarations 102 4.3.1 Typedeclarations 102 4.3.2 Constantdeclarations 104 4.3.3 Variabledeclarations 104 4.3.4 Proceduredefinitions 105 4.3.5 Collateraldeclarations 105 4.3.6 Sequentialdeclarations 106 4.3.7 Recursivedeclarations 107 4.3.8 Scopesofdeclarations 108 4.4 Blocks 108 4.4.1 Blockcommands 109 4.4.2 Blockexpressions 110 4.4.3 TheQualificationPrinciple 110 Summary 111 Furtherreading 112 Exercises 112 5 Proceduralabstraction 115 5.1 Functionproceduresandproperprocedures 115 5.1.1 Functionprocedures 116 5.1.2 Properprocedures 118 5.1.3 TheAbstractionPrinciple 120 5.2 Parametersandarguments 122 5.2.1 Copyparametermechanisms 124 5.2.2 Referenceparametermechanisms 125 5.2.3 TheCorrespondencePrinciple 128 5.3 Implementationnotes 129 5.3.1 Implementationofprocedurecalls 130 5.3.2 Implementationofparametermechanisms 130 Summary 131 Furtherreading 131 Exercises 131 Part III: Advanced Concepts 133 6 Dataabstraction 135 6.1 Programunits,packages,andencapsulation 135 6.1.1 Packages 136 6.1.2 Encapsulation 137 6.2 Abstracttypes 140 6.3 Objectsandclasses 145 6.3.1 Classes 146 6.3.2 Subclassesandinheritance 151

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.