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

1 / 24
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功