您好,欢迎访问三七文档
当前位置:首页 > 商业/管理/HR > 销售管理 > The Common Lisp Object System
TheCommonLispObjectSystem:AnOverviewbyLindaG.DeMichielandRichardP.GabrielLucid,Inc.MenloPark,California1.AbstractTheCommonLispObjectSystemisanobject-orientedsystemthatisbasedontheconceptsofgenericfunctions,multipleinheritance,andmethodcombination.AllobjectsintheObjectSystemareinstancesofclassesthatformanextensiontotheCommonLisptypesystem.TheCommonLispObjectSystemisbasedonameta-objectprotocolthatrendersitpossibletoalterthefundamentalstructureoftheObjectSystemitself.TheCommonLispObjectSystemhasbeenproposedasastandardforANSICommonLispandhasbeententativelyendorsedbyX3J13.2.HistoryoftheCommonLispObjectSystemTheCommonLispObjectSystemisanobject-orientedprogrammingparadigmde-signedforCommonLisp.Thelackofastandardizedobject-orientedextensionforCommonLisphaslongbeenregardedasashortcomingbytheCommonLispcommunity.Twosepa-rateandindependentgroupsbeganworkonanobject-orientedextensiontoCommonLispseveralyearsago.OnegroupisSymbolics,Inc.withNewFlavors,andtheotherisXeroxPARCwithCommonLoops.Duringthesummerof1986,thesetwogroupsmettoexplorecombiningtheirdesignsforsubmissiontoX3J13,atechnicalworkinggroupchargedwithproducinganANSIstandardforCommonLisp.AtthetimeoftheexploratorymeetingsbetweenSymbolicsandXerox,theauthorsofthispaperbecameinvolvedinthetechnicaldesignwork.ThemajorparticipantsinthiseffortwereDavidMoonandSonyaKeenefromSymbolics,DanielBobrowandGregorKiczalesfromXerox,andRichardGabrielandLindaDeMichielfromLucid.§2HistoryoftheCommonLispObjectSystemByMarch1987thisthree-waycollaborativeefforthadproducedastrongdraftofaspecificationforthebulkoftheObjectSystem.X3J13hasvotedanendorsementofthatspecificationdraft,statingthatitwouldalmostcertainlybeadoptedaspartofthestandardandencouragingimplementorstoproceedwithtrialimplementations.ThispaperisareportonthespecificationthatwaspresentedtoX3J13.3.TheCommonLispObjectSystemViewofObject-OrientedProgrammingSeveralaspectsoftheObjectSystemstandoutuponinspection:a)itisalayeredsystemdesignedforflexibility;b)itisbasedontheconceptofgenericfunctionsratherthanonmessage-passing;c)itisamultipleinheritancesystem;d)itprovidesapowerfulmethodcombinationfacility;e)theprimaryentitiesofthesystemareallfirst-classobjects.3.1TheLayeredApproachOneofthedesigngoalsoftheObjectSystemistoprovideasetoflayersthatseparatedifferentprogramminglanguageconcernsfromoneanother.ThefirstleveloftheObjectSystemprovidesaprogrammaticinterfacetoobject-orientedprogramming.Thislevelisdesignedtomeettheneedsofmostserioususersandtoprovideasyntaxthatiscrispandunderstandable.ThesecondlevelprovidesafunctionalinterfaceintotheheartoftheObjectSystem.Thislevelisintendedfortheprogrammerwhoiswritingverycomplexsoftwareoraprogrammingenvironment.Thefirstleveliswrittenintermsofthissecondlevel.Thethirdlevelprovidesthetoolsfortheprogrammerwhoiswritinghisownobject-orientedlanguage.ItallowsaccesstotheprimitiveobjectsandoperatorsoftheObjectSystem.ItisthislevelonwhichtheimplementationoftheObjectSystemitselfisbased.ThelayereddesignoftheObjectSystemisfoundedonthemeta-objectprotocol,aprotocolthatisusedtodefinethecharacteristicsofanobject-orientedsystem.Byusingthemeta-objectprotocol,otherfunctionalorprogrammaticinterfacestotheObjectSystem,aswellasotherobjectsystems,canbewritten.3.2TheGenericFunctionApproachTheCommonLispObjectSystemisbasedongenericfunctionsratherthanonmessage-passing.Thischoiceismadefortworeasons:1)therearesomeproblemswithmessage-passinginoperationsofmorethanoneargument;2)theconceptofgenericfunc-tionsisageneralizationoftheconceptofordinaryLispfunctions.§3TheCommonLispObjectSystemViewofObject-OrientedProgrammingAkeyconceptinobject-orientedsystemsisthatgivenanoperationandatupleofobjectsonwhichtoapplytheoperation,thecodethatismostappropriatetoperformtheoperationisselectedbasedontheclassesoftheobjects.Inmostmessage-passingsystems,operationsareessentiallypropertiesofclasses,andthisselectionismadebypackagingamessagethatspecifiestheoperationandtheobjectstowhichitappliesandsendingthatmessagetoasuitableobject.Thatobjectthentakesresponsibilityforselectingtheappropriatepieceofcode.Thesepiecesofcodearecalledmethods.Withunaryoperations,thechoiceofasuitableobjectisclear.Withmultiaryop-erations,however,message-passingsystemsrunintoproblems.Therearethreegeneralapproachestotheproblemofselectingasuitableobjecttowhichtosendamessage:cur-rying,delegation,anddistributionofmethods.Curryingisatechniqueforturningamultiaryoperationintoseriesofunaryoperations.Inmessage-passingsystems,thisisaccomplishedbyhavingtheobjectsinquestionsendmessagesamongthemselvestogatherthecontributionsofeachobjecttothefinalresultoftheoperation.Forexample,addingasequenceofnumberscanbedonebyaskingeachnumbertoadditselftosomeaccumulatedtotalandthentosendamessagetothenextobjectforittodothesame.Everyobjectmustknowhowtostartandendthisprocess.Curryingmayresultinacomplicatedmessage-passingstructure.Delegationisatechniquewherebyanobjectisdefinedtohandleanoperationonanumberofotherobjects.Forexample,tosumasequenceofnumbers,therecanbeanobjectthatwillacceptamessagecontainingtheidentitiesofthenumbersandthenperformthead
本文标题:The Common Lisp Object System
链接地址:https://www.777doc.com/doc-5545016 .html