1In:CombinatorsandFunctionalProgrammingLanguagesG.Cousineau,P-L.CurienandB.RobinetEditors,LectureNotesinComputerSciencen.242,Springer-Verlag,1986AmberLucaCardelli1AT&TBellLaboratories,MurrayHill,NJ07974IntroductionTheAmberlanguageembedsmanyrecentideasinprogramminglanguagedesign,andtriestointroduceallthefeaturesintheirminimal,essential,form.Oneofitsmaingoalsistosafelyblendstatictypingwiththedynamicrequirementsofasystemprogramminglanguage.Forthispurpose,multipleinheritanceandpersistentobjectsareintegratedinastronglytypedlanguage.Otherfeaturesincludegraphics,higher-orderfunctions,modulesandconcurrency.Amberisaspin-offoftheMLprogramminglanguage[Milner84].TheMLlanguageisnowbeingstandardized,andassuchisnotverysuitableforexperimentation.Amberisintendedasatoolfortryingoutnewideasinlanguageimplementation,languagedesign,andlanguageenvironments,whilebeingdeeplyinfluencedbytheMLexperience.Asaprogramminglanguage,Amberwasdefinedtoexperimentwithanewstyleofpolymorphism[Cardelli84b]which,unliketheML-styleparametricpolymorphism[Milner78],isbasedonanotionoftypeinclusion,andcanbeusedtointerpretmanyprogrammingconceptsfoundinobject-orientedlanguages[GoldbergRobson83].Inthisview,themainfeaturesoffunctionalandobject-orientedlanguagescanbenaturallyintegrated,andthecombinationofhigher-orderfunctionsandmultipleinheritancecanbestronglytyped.SometypecheckinganomaliesarestillpresentinAmber,andcurrentresearchisaimedatsolvingthemandintegratinginclusionpolymorphismwithparametricpolymorphism.Typeinclusionalsoplaysanimportantroleinmodularization.Amberprogramscanbepartitionedintomodulesandseparatelycompiled.Moduleshaveimport-exportlistsfortypesandvalues.Whenatypeisimported,itsactualdefinitionisnotaccessible:thisisaformofdataabstractionrealizedthroughthemodulemechanism,andimpliesthatmodulescanbecompiledinanyorder.Itispossibletospecifythattwoimportedtypes,althoughunknown,areoneasubtypeoftheother,sothatinheritancecanbemadetoworkacrossmoduleboundaries.Attheprogrammingsystemlevel,theimplementationisheavilybasedontheabilitytoexportandimportarbitraryvaluesto/frompersistentstorage.Thisfeatureisprovidedatthe1Currentaddresss:DECSRC,130LyttonAve,PaloAlto,CA94301.2lowestlevel,andguaranteesthepreservationofanycircularityorsharingpresentinthedatastructures.Asthelanguageisstaticallyscopedandtheimplementationoffunctionsisbasedonclosures,exportingafunctionwillautomaticallyexporteverythingthefunctionneedstorunwhenitisimported.Complexdatastructures,liketreesorfonts,canbeexportedandimportedwithouthavingtowritead-hocroutinestounparseandreparsethem.Separatecompilationisalsobasedonpersistence,andinvolvesimportingandexportingmoduledatastructures.Moreover,persistentdataarestronglytyped,sothatatypeerrorisgenerated(atruntime)ifonehappenstoimportthewrongkindofobject.Alimitationisthatonecanonlyimport/exportwholeobjects;hopefullyaschemewillbefoundtostorepartialobjects,alongthelinesof[AtkinsonBaileyChisholmCockshottMorrison83].Attheimplementationlevel,theAmbersystemisorganizedinthreelayers.Atthebottomthereisakernelwhichprovidesinput-output,graphics,heapmanagementand(inthefuture)processscheduling.Heapmanagementconsistsofdataallocation,collectionandpersistentstorage.Thislevelislargelyindependentofanyparticularlanguage,andonlydealswithfourbasicdataformats:immediates(suchasbooleans,integersandpointers),stringsofbytes,arraysofimmediatesandbitmaps.Thesecondlayerisanabstractmachine,similartotheonein[Cardelli84a],whichprovidesaninstructionsetanddatatypes(suchasrecords,functionalclosures,etc.)basedontheunderlyingdataformats.Programsareatthemomentencodedasbytestreamstobeinterpreted,butnothingwouldpreventthemfrombeingcompiledtomachinecode(exceptforportabilityconsiderations).Thislevelismildlylanguage-dependent,andcanbeusedtoimplementdifferentlanguagesinthesamegenericclasswithfewchanges.ThethirdlayeristhecompiledAmbercompiler,anditssourcewhichiswritteninAmber.Thecompilerhasalreadygonethroughdozensofgenerations,eachtimerecompilinganewversionofitself.ThesystemhasbeenportedtothreedifferentmachinesandcurrentlyrunsonanAppleMacintosh.FeaturesThissectionsummarizesthemainlanguagefeatures,beforegoingintomoredetailinthefollowingsections.Amberisinteractive.Everytimeaphraseisenteredatthetoplevel,thephraseisanalyzed,compiledandexecuted.Aphrasecanbeassimpleasevaluating1+2,orascomplicatedascompilingandlinkingaprogrammodule.Amberisstaticallyscoped.Everyvariableisboundtothenearestenclosingdefiningoccurrenceofthatvariable.Functionsreferringtoglobalvariablescanbetreatedasself-containedobjectswhichcanbepassedtootherfunctions,returnedfromotherfunctions,storedintodatastructuresandexportedtopersistentstorage.Staticscopingisalsorespectedatthetoplevel.Amberisasafelanguage.Staticanddynamictypecheckingensurestheconsistentuseofdataandoperations.Typecheckingismostlystatic,withsomeprovisionsfordynamicchecks,3asdescribedbelow.Amberhassafedynamictypes.Anyvalueinthelanguagecanbebundledintoadynamicvalue,whichcarriesitsfulltypewithit.Dynamicvaluescanlaterbecoercedtosomespecifictype,strippingthemofthedynamictypeinformati
本文标题:G.Cousineau, P-L.Curien and B.Robinet Editors,
链接地址:https://www.777doc.com/doc-5732926 .html