/
LANGUAGEPRIMITIVESANDTYPEDISCIPLINEFORSTRUCTUREDCOMMUNICATION-BASEDPRO LANGUAGEPRIMITIVESANDTYPEDISCIPLINEFORSTRUCTUREDCOMMUNICATION-BASEDPRO

LANGUAGEPRIMITIVESANDTYPEDISCIPLINEFORSTRUCTUREDCOMMUNICATION-BASEDPRO - PDF document

yoshiko-marsland
yoshiko-marsland . @yoshiko-marsland
Follow
372 views
Uploaded On 2016-07-13

LANGUAGEPRIMITIVESANDTYPEDISCIPLINEFORSTRUCTUREDCOMMUNICATION-BASEDPRO - PPT Presentation

DeptofComputerScienceUniversityofEdinburghUKDeptofComputerScienceUniversityofLisbonPortugalDeptofComputerScienceChibaUniversityofCommerceJapan procedurecallThesituationmaybeillustratedinc ID: 402680

Dept.ofComputerScience UniversityofEdinburgh UK.Dept.ofComputerScience UniversityofLisbon Portugal.Dept.ofComputerScience ChibaUniversityofCommerce Japan. procedurecall.Thesituationmaybeillustratedinc

Share:

Link:

Embed:

Download Presentation from below link

Download Pdf The PPT/PDF document "LANGUAGEPRIMITIVESANDTYPEDISCIPLINEFORST..." is the property of its rightful owner. Permission is granted to download and print the materials on this web site for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.


Presentation Transcript

LANGUAGEPRIMITIVESANDTYPEDISCIPLINEFORSTRUCTUREDCOMMUNICATION-BASEDPROGRAMMINGKOHEIHONDA,VASCOT.VASCONCELOS,ANDMAKOTOKUBOAbstract.Weintroducebasiclanguageconstructsandatypedisciplineasafoun-dationofstructuredcommunication-basedconcurrentprogramming.Theconstructs,whichareeasilytranslatableintothesummation-lessasynchronous-calculus,allowprogrammerstoorganiseprogramsasacombinationofmultiple owsof(possiblyunbounded)reciprocalinteractionsinasimpleandelegantway,subsumingthepre-cedingcommunicationprimitivessuchasmethodinvocationandrendez-vous.TheresultingsyntacticstructureisexploitedbyatypedisciplinealaML,whicho ersahigh-leveltypeabstractionofinteractivebehavioursofprogramsaswellasguar-anteeingthecompatibilityofinteractionpatternsbetweenprocessesinawell-typedprogram.Afterpresentingtheformalsemantics,theuseoflanguageconstructsisillustratedthroughexamples,andthebasicsyntacticresultsofthetypedisciplineareestablished.Implementationconcernsarealsoaddressed.IntroductionRecently,signi canceofprogrammingpracticebasedoncommunicationamongpro-cessesisrapidlyincreasingbythedevelopmentofnetworkedcomputing.FromnetworkprotocolsovertheInternettoserver-clientsystemsinlocalareanetworkstodistributedapplicationsintheworldwidewebtointeractionbetweenmobilerobotstoaglobalbankingsystem,theexecutionofcomplex,reciprocalcommunicationamongmultipleprocessesbecomesanimportantelementintheachievementofthegoalsofapplica-tions.Manyprogramminglanguagesandformalismshavebeenproposedsofarforthedescriptionofsoftwarebasedoncommunication.Asprogramminglanguages,wehaveCSP[9],Ada[33],languagesbasedonActors[2],POOL[4],ABCL[39],ConcurrentSmalltalk[38],ormorerecentlyPictandother-calculus-basedlanguages[7,27,34,13].Asformalisms,wehaveCCS[19],TheoreticalCSP[10],-calculus[22],andotherprocessalgebras.Inanothervein,wehavefunctionalprogramminglanguagesaugmentedwithcommunicationprimitives,suchasCML[30],dML[25],andConcurrentHaskell[15].Intheselanguagesandformalisms,variouscommunicationprimitiveshavebeeno ered(suchassynchronous/asynchronousmessagepassing,remoteprocedurecall,method-callandrendez-vous),andthedescriptionofcommunicationbehaviourisdonebycombin-ingtheseprimitives.Whatweobserveintheseprimitivesisthat,whiletheydoexpressone-timeinteractionbetweenprocesses,thereisnoconstructtostructureaseriesofreciprocalinteractionsbetweentwopartiesassuch.Thatis,theonlywaytorepresentaseriesofcommunicationsfollowingacertainscenario(thinkofinteractionsbetweena leserveranditsclient)istodescribethemasacollectionofdistinct,unrelatedin-teractions.Inapplicationsbasedoncomplexinteractionsamongconcurrentprocesses,whichareappearingmoreandmoreinthesedays,thelackofstructuringmethodswouldresultinlowreadabilityandcarelessbugsin nalprograms,apartfromthecasewhenthewholecommunicationbehaviourcanbesimplydescribedas,say,aone-timeremote Dept.ofComputerScience,UniversityofEdinburgh,UK.Dept.ofComputerScience,UniversityofLisbon,Portugal.Dept.ofComputerScience,ChibaUniversityofCommerce,Japan. procedurecall.Thesituationmaybeillustratedincomparisonwiththedesignhistoryofimperativeprogramminglanguages.Inearlyimperativelanguages,programswereconstructedasabaresequenceofprimitiveswhichcorrespondtomachineoperations,suchasassignmentandgoto(considerearlyFortran).Asiswell-known,asmorepro-gramsinlargesizewereconstructed,ithadbecomeclearthatsuchamethodleadstoprogramswithoutlucidity,readabilityorveri ability,sothatthenotionofstructuredprogrammingwasproposedin1970's.Inpresentdays,havingthelanguageconstructsforstructuredprogrammingisanorminimperativelanguages.Suchacomparisonraisesthequestionastowhetherwecanhaveasimilarstructuringmethodinthecontextofcommunication-basedconcurrentprogramming.Itsobjectiveistoo erabasicmeanstodescribecomplexinteractionbehaviourswithclarityanddisciplineatthehigh-levelofabstraction,togetherwithaformalbasisforveri cation.Itskeyelementswould,aboveall,consistof(1)thebasiccommunicationprimitives(correspondingtoassignmentandarithmeticoperationsintheimperativesetting),and(2)thestructuringconstructstocombinethem(correspondingto\if-then-else"and\while").Veri cationmethodologiesontheirbasisshouldthenbedeveloped.Thepresentpaperproposesstructuringprimitivesandtheaccompanyingtypedisci-pline,asabasicstructuringmethodforcommunication-basedconcurrentprogramming.Theproposedconstructshaveasimpleoperationalsemantics,andvariouscommuni-cationpatterns,includingthoseoftheconventionalprimitivesaswellasthosewhichgobeyondthem,arerepresentableastheircombinationwithclarityandrigoratthehigh-levelofabstraction.Thetypedisciplineplaysafundamentalrole,guaranteeingcompatibilityofinteractionpatternsamongprocessesviaatypeinferencealgorithminthelineofML[23].Concretelyourproposalconsistsofthefollowingkeyideas.Abasicstructuringconceptforcommunication-basedprogramming,calledsessionAsessionisachainofdyadicinteractionswhosecollectionconstitutesaprogram.Asessionisdesignatedbyaprivateportcalledchannel,throughwhichinterac-tionsbelongingtothatsessionareperformed.Channelsformadistinctsyntacticdomain;itsdi erentiationfromtheusualportnamesisabasicdesigndecisionwetaketomakethelogicalstructureofprogramsexplicit.Otherthansession,thestandardstructuringconstructsforconcurrentprogramming,parallelcompo-sitionnamehidingconditionalandrecursionareprovided.Inparticularthecombinationofrecursionandsessionallowstheexpressionofunboundedthreadofinteractionsasasingleabstractionunit.Threebasiccommunicationprimitives,valuepassinglabelbranching,anddelega-tion.The rstisthestandardsynchronousmessagepassingasfoundine.g.CSP-calculus.Thesecondisapuri edformofmethodinvocation,deprivedofvaluepassing.Thethirdisforpassingachanneltoanotherprocess,thusallowingaprogrammertodynamicallydistributeasinglesessionamongmultipleprocessesinawell-structuredway.Togetherwiththesessionstructure,thecombinationoftheseprimitivesallowsthe exibledescriptionofcomplexcommunicationstruc-tureswithclarityanddiscipline.basictypedisciplineforthecommunicationprimitives,asanindispensableele-mentofthestructuringmethod.Thetypabilityofaprogramensurestwopossiblycommunicatingprocessesalwaysowncompatiblecommunicationpatterns.Forex-ample,aproceduralcallhasapatternofoutput-inputfromthecaller'sviewpoint;thenthecalleeshouldhaveacommunicationpatternofinput-output.Becausein-compatibilityofinteractionpatternsbetweenprocesseswouldbeoneofthemainreasonsforbugsincommunication-basedprogramming,webelievesuchatype disciplinehasimportantpragmaticsigni cance.Thederivedtypegiveshigh-levelabstractionofinteractivebehavioursofaprogram.Becausecommunicationbetweenprocessesoverthenetworkcanbedonebetweenmod-uleswrittenindi erentprogramminglanguages,theproposedcommunicationconstructsmayaswellbeusedbyembeddingtheminvariousprogramminglanguages;howeverforsimplicitywepresentthemasaself-containedsmallprogramminglanguage,whichhasbeenstrippedtothebarestminimumnecessaryforexplanationofitsnovelfea-tures.Usingthelanguage,thebasicconceptoftheproposedconstructsisillustratedthroughprogrammingexamples.Theyshowhowextantcommunicationprimitivessuchasremoteprocedural-callandmethodinvocationcanbeconciselyexpressedasses-sionsofspeci cpatterns(hencewithspeci ctypeabstractions).Theyalsoshowhowsessionscanrepresentthosecommunicationstructureswhichdonotconformtothepre-cedingprimitivesbutwhichwouldnaturallyariseinpractice.Thissuggeststhatthesession-basedprogramorganisationmayconstituteasynthesisofanumberoffamiliaraswellasnewprogrammingideasconcerningcommunication.Wealsoshowthepro-posedconstructscanbesimplytranslatableintotheasynchronouspolyadicwithbranching[36].Thissuggeststhefeasibilityofimplementationindistributedenvi-ronment.Yetmuchremainstobestudiedconcerningtheproposedstructuringmethod,includingtheecientimplementationoftheconstructsandtheaccompanyingreasoningprinciples.SeeSection6formorediscussions.Thetechnicalcontentofthepresentpaperisdevelopedonthebasisoftheprecedingproposal[32]duetoKakuTakeuchiandthepresentauthors.Themaincontributionsofthepresentproposalincomparisonwith[32]are:thegeneralisationofsessionstructurebydelegationandrecursivesessions,whichde nitelyenlargestheapplicabilityoftheproposedstructuringmethod;thetypingsystemincorporatingthesenovelconcepts;rep-resentationofconventionalcommunicationprimitivesbythestructuringconstructs;andbasicprogrammingexampleswhichshowhowtheconstructs,inparticularthroughtheuseoftheabovementionednovelfeatures,canlucidlyrepresentcomplexcommunicationstructureswhichwouldnotbeamenabletoconventionalcommunicationprimitives.Intherestofthepaper,Section2introducesthelanguageprimitivesandtheirop-erationalsemantics.Section3illustrateshowtheprimitivesallowcleanrepresentationofextantcommunicationprimitives.Section4showshowtheprimitivescanrepresentthoseinteractionstructuresbeyondthoseoftheconventionalcommunicationprimitivesthroughkeyprogrammingexamples.Section5presentsthetypingsystemandestab-lishesthebasicsyntacticresults.Section6concludeswithdiscussionsontheimplemen-tationconcerns,relatedworksandfurtherissues.SyntaxandOperationalSemantics2.1.BasicConcepts.Thecentralideainthepresentstructuringmethodisasion.Asessionisaseriesofreciprocalinteractionsbetweentwoparties,possiblywithbranchingandrecursion,andservesasaunitofabstractionfordescribinginteraction.Communicationsbelongingtoasessionaredoneviaaportspeci ctothatsession,calledchannel.Afreshchannelisgeneratedwheninitiatingeachsession,fortheuseincom-municationsinthesession.Weusethefollowingsyntaxfortheinitiationofasession.initiationofsession rstrequests,viaaname,theinitiationofasessionaswellasthegenerationofafreshchannel,thenwouldusethechannelforlatercommunications.,ontheotherhand,receivestherequestfortheinitiationofasessionvia generatesanewchannel,whichwouldbeusedforcommunicationsin.Intheabovegrammar,theparenthesis()andthekeywordshowsthebindinganditsscope.Thus,in,thepart()bindsthefreeoccurrencesof.Thisconventionisuseduniformlythroughoutthepresentpaper.Viaachannelofasession,threekindsofatomicinteractionsareperformed:valuesending(includingnamepassing),branchingandchannelpassing(ordelegationione1en];Pk?(x1xn)inPdatasending/receivingsending/receiving[]ln:Pnglabelselection/branchingingk0];Pcatchk(k0)inPchannelsending/receiving(delegation)Datasending/receivingisthestandardsynchronousmessagepassing.Heredenotesanexpressionsuchasarithmetic/booleanformulaeaswellasnames.Weassumevari-ablesarealldistinct.Wedonotconsiderprogrampassingforsimplicity,cf.[12].branching/selectionistheminimisationofmethodinvocationinobject-basedpro-gramming.;::;llabelswhichareassumedtobepairwisedistinct.Thechannelsending/receiving,whichweoftencalldelegation,passesachannelwhichisbeingusedinasessiontoanotherprocess,thusradicallychangingthestructureofasession.Delega-tionisthegeneralisationoftheconceptwiththesamenameoriginallyconceivedintheconcurrentobject-orientedprogramming[40].SeeSection4.3fordetaileddiscussions.Inpassingwenotethatitstreatmentdistinctfromtheusualvaluepassingisessentialforbothdisciplinedprogrammingandatractabletypeinference.Communicationprimitives,organisedbysessions,arefurthercombinedbythefol-lowingstandardconstructsinconcurrentprogramming.concurrentcompositionname/channelhidingconditionalWedonotneedsequencingsinceeachcommunicationprimitivealreadyaccompaniesone.Wealsouse,theinaction,whichdenotesthelackofaction(actingastheunitof").Hidingdeclaresaname/channeltobelocalinitsscope(here).Channelhidingmaynotbeusedforusualprogramming,butisneededfortheoperationalsemanticspresentedlater.Inconditional,shouldbeabooleanexpression.Inrecursion,processvariable,wouldoccurinandzeroormoretimes.Identi ersin~shouldbepairwisedistinct.Wecanusereplication(orasinglerecursion)toachievethesamee ect,butmultiplerecursionispreferableforwell-structuredprograms.This nishestheintroductionofalllanguageconstructsweshalluseinthispaper.Wegiveasimpleexampleofaprogram.![1];];x+1];The rstprocessreceivesarequestforanewsessionvia,generates,sends1andreceivesareturnvaluevia,whilethesecondrequeststheinitiationofasessionviareceivesthevalueviathegeneratedchannel,thenreturnstheresultofadding1tothevalue.Observethecompatibilityofcommunicationpatternsbetweentwoprocesses.2.2.SyntaxSummary.Wesummarisethesyntaxwehaveintroducedsofar.Basesetsnames,rangedoverbya;b;:::channels,rangedoverbyk;k,rangedoverbyx;y;:::constants(includingnames,integersandbooleans),rangedoverbyc;cexpressions(includingconstants),rangedoverbye;elabels,rangedoverl;l;andprocessvariables,rangedoverbyX;Y;:::u;udenotenamesand channels.Thenprocesses,rangedoverbyP;Q:::,aregivenbythefollowinggrammar.sessionrequestsessionacceptance![~datasending?(~datareceptionlabelselectionelection[]ln:Pnglabelbranchingingk0];Pchannelsendingchannelreceptionconditionalbranchparallelcompositioninactionname/channelhidingidinge~k]processvariablesdeclarationforrecursionTheassociationof\"istheweakest,othersbeingthesame.Parenthesis()denotesbinderswhichbindthecorrespondingfreeoccurrences.Thestandardsimultaneoussub-stitutionisused,writinge.g..c=~x].Thesetsoffreenames/channels/variables/processvariablesofsay,de nedinthestandardway,arerespectivelydenotedbyfn(fc(fv(andfpv().Thealpha-equalityiswritten.Wealsosetfu(=fc((fn(P).Processeswithoutfreevariablesorfreechannelsarecalledprograms2.3.OperationalSemantics.Fortheconcisede nitionoftheoperationalsemanticsofthelanguageconstructs,weintroducethestructuralequality(cf.[5,20]),whichisthesmallestcongruencerelationonprocessesincludingthefollowingequations.3.(uuuu)iffu(),(4.()iffpv(fpv(iffpv(fpv(Nowtheoperationalsemanticsisgivenbythereductionrelation,denotedwhichisthesmallestrelationonprocessesgeneratedbythefollowingrules.ules.Link](accepta(k)inP1)j(requesta(k)inP2)!(k)(P1jP2)[Com![~?(~~c=~x](~~Labell[]ln:Png)!PjPi(1in)[Passsk0];P1)j(catchk(k0)inP2)!P1jP2[If11If22Def]defDin(X[~e~k]jQ)!defDin(P[~c=~x]jQ)(~c;XXScop]P!P0)(u)P!(u)P0[ParrStr]PP0andand Aboveweassumethestandardevaluationrelationonexpressionsisgiven.Wewriteforthere exive,transitiveclosureof.Notehowafreshchannelisgeneratedin[ruleastheresultofinteraction(inthiswaycorrespondstotheboundoutput-calculus[22]).Inthe[Label]rule,oneofthebranchesisselected,discardingtheremainingones.Notewedonotallowreductionundervariouscommunicationpre xes,asinstandardprocesscalculi.Asanexample,thesimpleprogramin2.1hasthefollowingreduction(belowandhenceforthweomittrailinginactions).![1];];x+1]![1];];x+1]))x+1]))=y]:Observehowinteractionproceedsinalock-stepfashion.Thisisduetothesynchronousformofthepresentcommunicationprimitives.RepresentingCommunication(1)ExtantCommunicationPrimitivesThissectiondiscusseshowstructuringprimitivescanrepresentwitheasethecommu-nicationpatternsofconventionalcommunicationprimitiveswhichhavebeeninuseinprogramminglanguages.Theyshowhowwecanunderstandtheextantcommunicationpatternsasa xedwayofcombiningtheproposedprimitives.3.1.Call-return.call-returnisawidelyusedcommunicationpatterninwhichaprocesscallsanotherprocess,thenthecalleewould,aftersomeprocessing,returnssomevaluetothecaller.Usuallythecallerjustwaitsuntilthereplymessagearrives.Thisconceptiswidelyusedasabasicprimitiveindistributedcomputingunderthenameofremoteprocedurecall.Wemayusethefollowingpairofnotationsforcall-return..e1en]inP;funf(x1xn)inP:Ontheright,thereturncommandnde]wouldoccurin.Assumetheseconstructsareaddedtothesyntaxin2.2.Asimpleprogrammingexamplefollows.Example3.1(Factorial)Fact(thenreturn[1])(Fact[[x�1]inreturnreturnxy])Hereandhenceforthwewrite,orasequenceofsuchequations,forthedeclarationpartofrecursion,leavingthebodypartimplicit.Thisexampleimplementsthestandardrecursivealgorithmforthefactorialfunction.[5]wouldgiveitsclientprocess.Thecommunicationpatternsbasedoncall-returnareeasilyrepresentablebythecombinationofrequest/acceptandsend/receive.We rstshowthemappingofthecaller.Below[[]]denotestheinductivemappingintothestructuringprimitives..x=calla[~e]inP]]def=requesta(k)ink![~~P]]:Naturallyweassumeischosenfresh.Thebasicscenarioisthatacaller rstinitiatesthesession,sendsthevalues,andwaitsuntilitreceivestheansweronthesamechannel.Ontheotherhand,thecalleeistranslatedasfollows::funa(~x)inP]]def=accepta(k)ink?(~~P]][ Here[[e]=return[e]]denotesthesyntacticsubstitutionoffe]foreachhe].Observethattheoriginal\return"operationisexpressedbythe\send"primitiveofthestructuringprimitives,cf.[20].Asoneexample,letusseehowthefactorialprograminExample3.1istranslatedbytheabovemapping.Example3.2(Factorial,translation)Fact(![1];)(Fact[[x�1];;xy])Noticehowtheusageofanddi erentiatesthetwocontextsofcommunication.Ifwecomposethetranslationoffactorialwiththatofitsuser,wehavethereduction:Fact[ct[y=callf[3]Fact[ct[P]][6Inthisway,thesemanticsofthesynchronouscall-returnisgivenbythatofthestruc-turingprimitivesviathetranslation.Someobservationsfollow.(1)Thesigni canceofthespeci cnotationsforcall-returnwouldlieinthedeclarationoftheassumed xedcommunicationpattern,whichwouldenhancereadabilityandhelpveri cation.Atthesametime,thetranslationretainsthesamelevelofclarityastheoriginalcode,evenifitdoesneedafewadditionalkeystrokes.(2)Intranslation,thecallerandthecalleeingeneralowncomplementarycommunica-tionpatterns,i.e.input-outputmeetsoutput-input.Howeverif,forexample,thereturncommandsappeartwiceinthecallee,thecomplementarityislost.Thisre-latestothenotionoftypeswediscusslater:indeed,non-complementarypatternsarerejectedbythetypingsystem.(3)Thetranslationalsosuggestshowstructuringprimitiveswouldgeneralisethetradi-tionalcall-returnstructure.Thatis,inadditiontothe xedpatternofinput-output(or,correspondingly,output-input),wecanhaveasequenceofinteractionsofindef-initelength.Forsuchprogrammingexamples,seeSection4.3.2.MethodInvocation.Theideaofmethodinvocationoriginatesinobject-orientedlanguages,whereacallercallsanobjectbyspecifyingamethodname,whiletheobjectwaitswithafewmethodstogetherwiththeassociatedcodes,sothat,wheninvoked,executesthecodecorrespondingtothemethodname.Thecallmayormaynotresultinreturningananswer.Asanotation,an\object"wouldbewritten::[]ln(~xn)inPng;whereagivesanobjectidenti er,;:::;larelabels(allpairwisedistinct)withformalparameters~,andgivesthecodecorrespondingtoeach.Thereturnaction,writtenne],mayoccurineachasnecessary.Acallerthenbecomes:a:lle]inPa:lle];P:Theleft-handsidedenotesaprocesswhichinvokestheobjectwithamethodtogetherwitharguments~,then,receivingtheanswer,assignstheresultto,and nallyexecutesthecontinuation.Theright-handsideisanotationforthecasewhentheinvocationdoesnotneedthereturnvalue.Asanexample,letusprogramasimplecell.Example3.3a;ccc]jCell[a;c])[]]a;x ThecellCell[a;c]denotesanobjectwhichsavesitsvalueinandhasaname.Therearetwomethods,and,eachwiththeobviousfunctionalities.Acallerwhich\reads"thisobjectwouldbewritten,forexample,,inP.Themethodinvocationcanberepresentedinthestructuringconstructsbycombininglabelbranchingandvaluepassing.Weshowthetranslationsofanobject,acallerwhichexpectsthereturn,andacallerwhichdoesnotexpectthereturn,inthisorder.order.obja:fl1(~x1)inP1[][]ln(~xn)inPng]]def=accepta(k)inkfl1:k?(~~P1]][][]ln:k?(~~Pn]]g[[x=a:lle]inP]]def=requesta(k)inkli;k![~~P]][[a:lle];P]]def=requesta(k)inkli;k![~];[[Ineachtranslation,shouldbefresh.Inthe rstequation,denotesthesubstitutionnk![e]=return[e]],replacingalloccurrencesofofe]byye].Observethatamethodinvocationisdecomposedintolabelbranchingandvaluepassing(cf.[37]).Usingthismapping,thecellisnowtranslatedinto:Example3.4(Cell,translation)a;cce];Cell[a;c][]]a;xSimilarly,,inPistranslatedas[3]becomes![3].Someobservationsfollow.(1)Thetranslationisnotmuchmorecomplexthantheoriginaltext.Thespeci cnotationhoweverhasaroleofdeclaringthe xedcommunicationpatternandsaveskey-strokes.(2)Hereagain,thetranslationofthecallerandthecalleeingeneralresultsincomple-mentarypatterns.Therearehowevertwomaincaseswherethecomplementarityislost,oneduetotheexistence/lackofthereturnstatement(e.g.[3]above)andanotherduetoaninvocationofanobjectwithanon-existentmethod.Againsuchinconsistencyisdetectablebyatypingsystemintroducedlater.(3)Thetranslationsuggestshowstructuringprimitivescangeneralisethestandardmethodinvocation.Forexample,anobjectmayinturninvokethemethodofthecallerafterbeinginvoked.Webelievethat,inprogrammingpracticebasedontheideaofinteractingobjects,suchreciprocal,continuousinteractionwouldarisenaturallyandusefully.Suchexamplesarediscussedinthenextsection.Inadditiontocall-returnandmethodinvocation,wecansimilarlyrepresentothercom-municationpatternsinusewithease,forexampleasynchronouscall-return(whichin-rendez-vous[33]andfuture[2])andsimplemessagepassing.Forthespacesakeweleavetheirtreatmentto[12].Section6givesabriefdiscussiononthesigni canceofspeci cnotationsforthese xedcommunicationpatternsinlanguagedesign.RepresentingCommunication(2)ComplexCommunicationPatternsThissectionshowshowthestructuringprimitivescancleanlyrepresentvariouscomplexcommunicationpatternswhichgobeyondthoserepresentedinconventionalcommuni-cationprimitives. 4.1.ContinuousInteractions.Thetraditionalcall-returnprimitivealreadyencapsu-latesasequenceofcommunications,albeitsimple,asasingleabstractionunit.Thekeypossibilityofthesessionstructureliesinthatitextendsthisideatoarbitrarilycom-plexcommunicationpatterns,includingthecasewhenmultipleinteractionsequencesinterleavewitheachother.Thefollowingshowsonesuchexample,whichdescribesthebehaviourofabankingservicetotheuser(essentiallyanautomatictellermachine).Example4.1(ATM)ATM(a;bbid];kfdeposit:requestb(h)ink?(amt)inhdeposit;h![id;amt];ATM[a;bbwithdraw:requestb(h)ink?(amt)inhwithdraw;h![id;amt];hfsuccess:kdispense;k![amt];ATM[a;bbfailure:koverdraft;ATM[a;bbbalance:requestb(h)inhbalance;h?(amt)ink![amt];ATM[a;bTheprogram,afterestablishingasessionwiththeuservia, rstletstheuserinputtheusercode(weomitsuchdetailsasveri cationofthecodeetc.),theno ersthreechoices,,and.Whentheuserselectsoneofthem,thecorrespondingcodeisexecuted.Forexample,whentheischosen,theprogramletstheuserentertheamounttobewithdrawn,theninteractswiththebankvia,askingwiththeusercodeandtheamount.Ifthebankanswersthereisenoughamountintheaccount,themoneyisgiventotheuser.Ifnot,thenthemessageresults.Ineithercasethesystemeventuallyreturnstotheoriginalwaitingmode.Noteinparticulartheprogramshouldcommunicatewiththebankinthemidstofinteractionwiththeuser,sothreepartiesareinvolvedininteractionasawhole.Ausermaybewrittenas:s:myId];kwithdraw;k![58];;overdraft:Qg:Herewemayconsiderasacodefor\exceptionhandling"(invokedwhenthebalanceislessthanexpected).Noticealsointeractionsarenowtrulyreciprocal.4.2.UnboundedInteractions.Thepreviousexampleshowshowstructuringprim-itivescaneasilydescribethesituationwhichwouldbediculttoprograminacleanwayusingtheconventionalprimitives.Atthesametime,thecodedoeshaveroomforamelioration.Ifauserwantstolookathisbalancebeforehewithdraws,heshouldenterhisusercodetwice.Thefollowingre nementmakesthisredundancyunnecessary. Example4.2(KindATM)ATMa;bbid];Actions[a;b;id;kActions(a;b;b;id;];Actions[a;b;id;kkwithdraw:requestb(h)ink?(amt)inhwithdraw;h![id];h![amt];hfsuccess:kdispense;k![amt];Actions[a;b;id;kkfailure:koverdraft;Actions[a;b;id;kkbalance:requestb(h)inhbalance;h?(amt)ink![amt];Actions[a;b;id;kkquit:ATMMa;bAscanbeseen,themaindi erenceliesinthattheprocessisstillwithinthesamesessionevenafterrecurringtothewaitingmode,afterprocessingeachrequest:onceauserestablishesthesessionandenterstheusercode,shecanrequestvariousservicesasmanytimesasshelikes.Toexitfromthisloop,thebranchisintroduced.Thisexampleshowshowrecursionwithinasessionallowsa exibledescriptionofinteractivebehaviourwhichgoesbeyondtherecursioninusualobjects(whereeachsessionconsistsofa xednumberofinteractions).Itisnotablethattheunboundedsessionownsarigoroussyntacticstructuresoastoallowtypeabstraction,seeSection5.Unboundedinteractionswitha xedpatternnaturallyariseinpractice,e.g.interactionsbetweena leserveranditsclient.Webelieverecursionwithinasessioncanbee ectivelyusedforvariedprogrammingpractice.4.3.Delegation.Theoriginalideaofdelegationinobject-basedconcurrentprogram-ming[40]allowsanobjecttodelegatetheprocessingofarequestitreceivestoanotherobject.Itsbasicpurposeisdistributionofprocessing,whilemaintainingthetrans-parencyofnamespaceforclientsofthatservice.Practicallyitcanbeusedtoenhancemodularity,toexpressexceptionhanding,andtoincreaseconcurrency.Thefollowingexampleshowshowwecangeneralisetheoriginalnotiontothepresentsetting.Example4.3(Ftpserver)Belowdenotesthe-foldparallelcomposition.Init(;nis)=()(Ftpd[FtpThread[b;nisFtpd(inrequestinthrowthrows];Ftpd[FtpThread(b;nisincatchuseridpasswdnissuseridpasswdsswdvalid:swelcome;Actions[s;bActions(s;b le;Actions[s;bbput:;s?( le;Actions[s;bbbye:;FtpThread[b;nisTheabovecodeshowsanoutlineofthecodeofaftpserver,whichfollowsthebehaviourofthestandardftpserverswithTCP/IPprotocol.InitiallytheprogramInitgeneratesaserverFtpdandthreadswiththeidenticalbehaviour(forsimplicityweassumeallthreadssharethesamename).Suppose,inthissituation,aserverreceivesarequestforaservicefromsomeclient,establishingthesessionchannel.Aserverthenrequestsforanothersessionwithanidlethread(ifitexists)and\throws"achannel tothatthread,whilegettingreadyforthenextrequestfromclientsitself.ItisnowthethreadFtpThreadwhichactuallyprocessestheuser'srequest,receivingtheusername,referringtoNIS,andexecutingvariousoperations(noterecursionwithinasessionisused).Herethedelegationisusedtoenabletheftpservertoprocessmultiplerequestsconcurrentlywithoutunduedelayinresponse.Theschemeisgenerallyapplicabletoaserverinteractingwithmanyclients.Someobservationsfollow.(1)Theexampleshowshowthegeneraliseddelegationallowsprogrammerstocleanlydescribethoseinteractionpatternswhichgeneralisetheoriginalformofdelegation.Otherexamplesoftheusageofdelegationabound,forexamplea leserverwithge-ographicallydistributedsitesoraserverwithmultipleserviceseachtobeprocessedbyadi erentsub-server.(2)Akeyfactoroftheabovecodeisthataclientdoesnothavetobeconsciousofthedelegationwhichtakesplaceontheserver'sside:thatis,aclientprogramcanbewrittenasifitisinteractingwithasingleentity,forexampleasfollows.ws.myId];sfsorry:[]welcome:gObservethat,betweentheinitialandthenextsendingoperation,theinteractiontakesplaceontheserver'sside:howevertheclientprocessdoesnothavetobeconsciousoftheevent.Thisshowshowdelegationenablesdistributionofcomputationwhilemaintainingthetransparencyofthenamespace.(3)Ifwealloweachftp-threadtobedynamicallygenerated,wecanuseparallelcom-positiontothesamee ect,justastheuseof\fork"topassprocessresourcesinUNIX.Whilethisschemehasalimitationinthatwecannotsendachanneltoanalreadyrunningprocess,ito ersanotherprogrammingmethodtorealise exible,dynamiccommunicationstructures.Wealsoobservethattheuseoforthe\fork"mentionedabove,wouldresultincomplexlywovensequencesofinter-actions,whichwouldbecomemoreerror-pronethanwithout.Insuchsituations,thetypedisciplinediscussedinthenextsectionwouldbecomeanindispensabletoolforprogramming,wherewecanalgorithmicallyverifyifaprogramhascoherentcom-municationstructureand,inparticular,ifitcontainsinteractionerrors.TheTypeDiscipline5.1.Preliminaries.Thepresentstructuringmethodallowsthecleardescriptionofcomplexinteractionstructuresbeyondconventionalcommunicationprimitives.Themorecomplextheinteractionbecomes,however,themoredicultitwouldbetocapturethewholeinteractivebehaviourandtowritecorrectprograms.Thetypedisciplineweshalldiscussinthissectiongivesasimplesolutiontotheseissuesatabasiclevel.We rstintroducethebasicnotionsconcerningtypes,includingdualityontypeswhichrepresentscomplementarityofinteractions.De nition5.1(Types)Giventypevariablest;t)andsortvariabless;ssortsS;S)andtypes ; ;:::)arede nedbythefollowinggrammar.bool ~S]; j#[ ]; j&fl1: 1;:::;ln: ngj1j?j"[~S]; j"[ ]; jf where,foratypeinwhichdoesnotoccur,wede ne ,theco-type,by: "[~S =#[~S]; li: igfli: ig "[ =#[ ]; 1=1 #[~S]; ="[~S]; &fli: ig=li: ig #[ ="[ ]; t=t t: =t: sorting(resp.atyping,resp.abasis)isa nitepartialmapfromnamesandvariablestosorts(resp.fromchannelstotypes,resp.fromprocessvariablestothesequencesofsortsandtypes).Welet�(resp.,resp.)rangeoversortings(resp.typings,resp.bases).Weregardtypesandsortsasrepresentingthecorrespondingregulartreesinthestandardway[6],andconsidertheirequalityintermsofsuchrepresentation.Asortofform representstwocomplementarystructuresofinteractionwhichareassociatedwithaname(onedenotingthebehaviourstartingwith,anotherthatwhichstartswith),whileatypegivestheabstractionofinteractiontobedonethroughachannel.Theco-typeofagiventypedenotesthecomplementarybehaviouroftheoriginaltype.Note holdswhenever isde ned.Letusgiveabriefdescriptionofeachformoftypes.Thetypee~S]; representsthebehaviourof rstinputtingvaluesofsorts,thendoestheactionsoftypee ]; representsthesimilarbehaviour,whichstartswiththechannelinput(catch)instead..~S]; andd ]; aredualoff~S]; andd ]; ,sendingvaluesinteadofreceiving.showsthebranchingbehaviour:itwaitswithoptions,andbehavesastype-thactionisselected(externalchoice).thenrepresentsthebehaviourwhichwouldselectoneofandthenbehavesasaccordingtotheselected(internalchoice).representstheinaction,actingastheunitofsequentialcomposition.denotesarecursivebehaviour,whichrepresentsthebehaviourofstartdoingand,whenisencountered,recurstoagain.Finallyisaspeci ctypeindicatingthatnofurtherconnectionispossibleatagivenname.Thefollowingpartialalgebraonthesetoftypings,cf.[11],playsakeyroleinourtypingsystem.De nition5.2(Typealgebra)Typingsandcompatible,writtenif )foralldom(dom().When,thecompositionofand,written,isgivenasatypingsuchthat()is(1),ifdom(dom();(2)),ifdom(dom(mod)forand(3)unde nedotherwise.Compatibilitymeanseachcommonchannelisassociatedwithcomplementarybe-haviours,thusensuringtheinteractionontorunwithouterrors.Whencomposed,thetypeforbecomes,preventingfurtherconnectionat(notehasnoco-type).Onecancheckthepartialoperationispartiallycommutativeandassociative.5.2.TypingSystem.Themainsequentofourtypingsystemhasaform;�whichreads:\undertheenvironment;�,aprocesshasatyping."Sorting�speci esprotocolsatthefreenamesof,whiletypingspeci es'sbehaviouratitsfreechannels.Whenisaprogram,andbecomebothempty.Givenatypingorasorting,say,writefors:pgtogetherwiththeconditionthatdom();andfortheresultoftakingo :()fromif( isde ned(ifnotwetakeitself).Alsoassumegiventheevidentinferencerulesforarithmeticandbooleanexpressions,whosesequenthastheform�,enjoyingthestandardpropertiessuchas�e.Sandimply�c.S.Themainde nitionofthissectionfollows.De nition5.3(Basictypingsystem)Thetypingsystemisde nedbytheaxiomsandrulesinFigure1,whereweassumetherangeofin[Inact]and[Var]containsonlyand Acc;� ;� Req];� ;� Send]�`~e.~S;� ;�![~~~S]; [Rcv;� ;�?(~~~S]; [Br];�;� ;��[]ln:Png.k:&fl1: 1;:::;l:::;lSel];� ;�;:::;l:;lThr];� ;��k0];P.k:"[ ]; k0: [Cat;� ;�� ]; [Conc;�;� ;��If]�`e.bool;�;� ;��NRes];� ;��CRes];� ;��Inact];��Var e~k].~k:~ [Def];�;� nX`Xx~kPX~S~ ) Figure1.ThetypingsystemForsimplicity,therule[]isrestrictedtosinglerecursion,whichiseasilyextendibletomultiplerecursion.If;�isderivableinthesystem,wesayistypableunder;�with,orsimplyistypable.Somecommentsonthetypingsystemfollow.(1)Inthetypingsystem,theleft-handsideoftheturnstileisforsharednamesandvariables(\classicalrealm"),whiletheright-handsideisforchannelssharableonlybytwocomplementaryparties(avariantof\linearrealm").Itdi ersfromvarioussortingdisciplinesinthatachannelisingeneralill-sorted,e.g.itmaycarryanintegeratonetimeandabooleanatanother.Inspiteofthis,themanipulationoflinearrealmbytypingalgebraensureslinearisedusageofchannels,aswellaspreventinginteractionerrors,cf.Theorem5.4below.(2)In[],thebehaviourrepresentedbyforchannelisactuallyperformedbytheprocesswhich\catches"(notecannotoccurfreein,henceneitherinbyourconventionon\").Tocapturetheinteractionsatasawhole, addedtothelinearrealm.Ontheotherhand,therule[Cat]guaranteesthatthereceivingsidedoesusethechannelasisprescribed.Readingfromtheconclusionstotheantecedents,[]and[Cat]togetherillustratehowis\thrown"fromthelefttotheright.(3)Thesimplicityofthetypingrulesisnotable,utilisingtheexplicitsyntacticstructureofsession.Inparticularitissyntax-directedandhasaprincipaltypewhenweuseaversionofkinding[26].ItistheneasytoshowthereisatypingalgorithmalaML,whichextractstheprincipaltypeofagivenprocessi itistypable.Itshouldbenotedthatsimplicityandtractabilityoftypingrulesdonotmeanthattheobtainabletypeinformationisuninteresting:theresultingtypeabstractionrichlyrepresentstheinteractivebehaviourofprograms,aslaterexamplesexhibit.Belowwebrie ysummarisethefundamentalsyntacticpropertiesofthetypingsystem.Weneedthefollowingnotion:aprocessisapre xedprocesswithsubject(suchas![~and).Next,a-redexisapairofdual-processescomposed,i.e.eitherofforms(![~),(([]ln:Qng),orrk0];Pjcatchk(k00)inQ).Thenisanerroris,forsome,the-compositionofeither-processesthatdonotformathreeormore-processes.Wethenhave:Theorem5.4.1.(Invarianceunder);�and;�2.(Subjectreduction);�and;�3.(Lackofrun-timeerrors)Atypableprogramneverreducesintoanerror.Theproofsarestraightforwardduetothesyntax-directednatureofthetypingrules.See[12]fordetails.WenotethatwecaneasilyextendthetypingsystemwithML-likepolymorphismforrecursion,whichisusefulfore.g.templateprocesses(suchasasa42]jCell[btrue]),withwhichallthepropertiesinTheorem5.4arepreserved.Thisandotherbasicextensionsarediscussedin[12].5.3.Examples.Wegiveafewexamplesoftyping,takingprogramsintheprecedingsections.Weomitthe nalfromthetype,e.g.wewritewrite ]forr ];1.First,thefactorialinExample3.2isassigned,atitsfreename,atypeenat];"[nat](forfactorial)anditsduallnat];#[nat](foritsuser).Next,thecellinExample3.3isgivenatypee ];write:#[ ]g(forthecell)anditsduall ];write:"[ ]g(foritsuser).Thetypeofacellsaysacellwaitswithtwooptions,and,when\read"isselected,itwouldsendanintegerandthesessionends,andwhen\write"isselected,itwouldreceiveanintegerandagainthesessionends:itsdualsaysausermaydoeither\read"or\write",and,accordingtowhichofthemitselects,itbehavesasprescribed.Asamoreinterestingexample,takethe\kindATM"inExample4.2.ConsiderATMMab]underthedeclarationintheexample.Thenatyping i:h giventotheprocess,whereweset,whichabstractstheinteractionwithauser,as: ,whichabstractstheinteractionwiththebankingsystem,isgivenas: natnatatnatnat];&&nat];#[nat]g:Notethatthetypeabstractionisgivenseparatelyfortheuser(at)andthebank(at),describingthebehaviourofATMforeachofitsinteractingparties.Alsonoticehowtherecursionininteractivebehaviourisrepresentedbyrecursionintypes.Asa nalexample,theftpserverofExample4.3isgiventhefollowingtypeatitsprincipalname:e:natnatggThisexampleshowsthatthethrow/catchactionisabstractedawayinthetypewithrespecttotheuser(butnotinthetypewithrespecttothethread,whichweomit)sothattheusercaninteractwithoutconcerninghimselfwiththedelegationoccurringontheother'sside.Intheseways,notonlythetypedisciplineo ersthecorrectnessveri cationofprogramsatabasiclevel,butalsoitgivesacleanabstractionofinteractivebehavioursofprograms,whichwouldassistprogrammingactivities.6.1.ImplementationConcerns.Intheprevioussections,wehaveseenhowtheses-sionstructureenablescleandescriptionofcomplexcommunicationbehaviours,employ-ingthesynchronousformofinteractionsasitsessentialelement.Forimplementationoftheprimitives,however,theuseofasynchronouscommunicationisessential,sincetherealdistributedcomputingenvironmentsareinherentlyasynchronous.Tostudysuchimplementationinaformalsetting,whichshouldthenbeappliedtotherealis-ticimplementation,weconsideratranslationofthepresentlanguageprimitivesintoCO[18],asortedsummation-lesspolyadicasynchronous-calculuswithbranchingstructure(whichisultimatelytranslatableintoitsmonadic,branch-lessversion).TheexistenceofthebranchingstructuremakesTCOanidealintermediatelanguage.Forthespacesakewecannotdiscussthetechnicaldetailsofthetranslation,forwhichthereadermayreferto[12].Weonlylistessentialpoints.(1)Thetranslationconvertsbothchannelsandnamesintonames.Eachsynchronousinteraction(includingthebranching-selection)istranslatedintotwoasynchronousinteractions,thesecondoneactingasacknowledgement.Thissuggeststheprimi-tivesareamenablefordistributedimplementation,atleastattherudimentarylevel.(2)Inspiteof(1)above,theresultingcodeisfarfromoptimal:asasimpleexample,ifavalueissentimmediatelyaftertherequestoperation,clearlythevaluecanbe\piggy-backed"totherequestmessage.ArelatedexampleisthetranslationofthefactorialinSection3incomparisonwithitsstandard\direct"encodinginPictorCOinacontinuation-passingstyle,cf.[28].To ndthee ective,well-foundedoptimisationmethodsinthislinewouldbeafruitfulsubjectofstudy(see6.2below).(3)Theencodingtranslatesthetypableprogramsintowell-sortedTCOcodes.Itisanintriguingquestionhowwecancapture,inapreciseway,thewell-typednessoftheoriginalcodeatthelevelofTCO(thisquestionwasoriginallyposedbySimonGayforaslightlydi erentkindoftranslation). 6.2.RelatedWorksandFurtherIssues.Inthefollowing,comparisonswithafewrelatedworksaregivenalongwithsomeofthesigni cantfurtherissues.First,inthecontextofconventionalconcurrentprogramminglanguages,thekeydepartureoftheproposedframeworkliesinthatthesessionstructureallowsustoformanarbitrarycomplexinteractionpatternasaunitofabstraction,ratherthanbeingrestrictedtoa xedrepertoire.ExamplesinSection4showhowthisfeatureresultsincleandescriptionofcomplexcommunicationbehaviourswhichmaynotbeeasytoexpressinconventionallanguages.Forexample,ifweuse,fordescribingthoseexamples,so-calledconcurrentobject-orientedlanguages[40],whoseprogrammingconceptbasedonobjectsandtheirinteractionisproximatetothepresentone,weneedtodivideeachseriesofinteractionsintomultiplechunksofindependentcommunications,which,togetherwiththenestingofmethodinvocations,wouldmaketheresultingprogramshardtounderstand.Theexplicittreatmentofsessionalsoenablesthetype-basedveri cationofcompatibilityofcommunicationpatterns,whichwouldfacilitatethewritingofcorrectcommunication-basedprogramsatanelementarylevel.Inspiteoftheseobservations,webelievethatvariouscommunicationprimitivesinexistingprogramminglanguages,suchasobject-invocationandRPC,wouldnotdimin-ishtheirsigni canceevenwhenthepresentprimitivesareincorporated.Wealreadydiscussedhowtheywouldbeusefulfordeclaring xedcommunicationpatterns,aswellasforsavingkeystrokes(inparticulartheprimitivesforsimplemessagepassingwouldbetterbegivenamonglanguageconstructssincetheirdescriptioninthestructuringprimitivesis,ifeasy,roundabout).Noticewecanstillmaintainthesametypedisciplinebyregardingtheseconstructsasstandingforcombinationofstructuringprimitives,aswedidinSection3.Inanothervein,thecommunicationstructureswhichwecanextractfromsuchdeclarationwouldgiveusefulinformationforperformingoptimisation.Secondly,regardingchannelsasportnamesusedinaspeci cway,weobservethatthesessionstructureisrealisedbynamepassingcommunication.Indeed,theencodingofvariousinteractionstructuresin-calculusisthestartingpointofthepresentseriesofstudy(cf.Section2of[32]).Inthiscontext,onemayobservethattherepresentationofcommunicationstructuresinthepresentprimitivesinSection3hasacloseresemblancewiththeencodingoffunctionsandobjectsin-calculusin,respectively,[20]and[37].Extractionoffundamentaloperationalstructuresomnipresentlyarisinginthepaststudy,aswellastheconsiderationofhowthesestructurescanbecombinedinawell-structuredfashion,ledtothepresentproposal.Acoupleofbasicobservationsarepossibleinthiscontext.(1)Thewell-sorted(synchronous)polyadic-calculuswithoutsummation,whichisusedinmostworksinthis eld,isasubsystemofthelanguageconstructsaspre-sentedinthispaper,byrepresentingpolyadicsynchronousnamesending/receptionbythecombinationsofrequest/data-sendingandaccept/data-reception,respec-tively.Wealreadynotedthatthereisansimpleencodingintheconversedirection;Thusthesheerexpressivenessdoesnotchange.(2)Inspiteoftheabovepoint,thereisabasicdi erencebetweenthe-calculusandthepresentedprogrammingconstructsasatoolforrepresentinginteractionstructures.Ontheonehand,-calculusissimpleand,amongothers,iseasytogiveseman-ticsbasedoninteractivebehaviourofprocesses.Thismakesitidealforthebasic Theuseof(guardedorgeneral)summationforbranching,asfoundin[37],hasthemeritofleavingno\garbages"afterselectionintheencodingofbranching,butisnotvitalforoperationalrepresentationorforreasoning(becausethementionedgarbagesarestronglybisimilartoinaction).Inthepresentsetting,theintroductionofexplicitbranchingmakestheencodingofbranchingbynamepassingitselfunnecessary. theoreticalstudy,ashasbeenalreadyattestedintheliterature.Inparticularthesemanticsofthepresentlanguageconstructswouldbestudiedfollowingthebasicideaswhichhaveariseninthestudyof-calculus,includingthosebasedonlabelledtransition(cf.[22])andthosebasedonnon-labelledtransition(cf.[]).Ontheotherhand,thepresentedstructuringmethodgivesbetterarticulationofprograms'behaviourthanthebareuseof-calculus,especiallywhenaseriesofreciprocalinteractionsbetweentwopartiesisinvolved,asisinmanycomplexcommunication-basedapplications.Noticethisisachievedthroughtheconstraintontheusageofchannels,formallystipulatedasthewell-typednesscondition.Thisconstraintin-deedprohibitscertainpossiblyinterestingwaysofusingchannels(suchasallowingracingconditionsforchannels);butitdoesleadtotheclari cationofcommunica-tionstructuresinprograms,whichenhancesreadabilityofprogramsandmakesitpossibletostaticallydetectincompatibilityincommunicationpatterns.Withrespecttothesecondpoint,itwouldbeinterestingtostudyhowwecanloosenthepresentconstraintonchannelsinmeaningfulwayswhilestillkeepingthebene tofthepresentframework,referringtovariouspossibilitiesasfoundin-calculi,aswellasconsideringpracticalconcerns.Thirdly,the eldofresearchwhichiscloselyrelatedtothepresentworkisthestudyofvarioustypedprogramminglanguagesbasedon-calculi[7,27,34]andoftypesfor-calculi(seeforexample[21,8,28,29,16,17,31,35,41]).Typesimposevariousconstraintsonthesyntaxofprocesses,andthusrestraintheprocessestohaveonly\good"interactivebehaviours.Variednotionsoftypeshavebeenstudiedinthecontext-calculusandthenhavebeenappliedtothesettingofprogramminglanguagesbased-calculi.Comparisonswiththeworksinthis eldmaybedonefromtwodistinctviewpoints,languagedesignconcernsandnotionsoftypes.(1)Fromtheviewpointoflanguagedesign,Pictandother-calculus-basedlanguagesusetheprimitivesof(polyadic)asynchronous-calculusoritsvariantsasthebasiclanguageconstructs,andbuildfurtherlayersofabstractionontheirbasis.Thepresentproposaldi ersinthatitincorporatesthesession-basedstructureasafun-damentalstratumforprogramming,ratherthanrelyingonchainsofdirectnamepassingfordescribingcommunicationbehaviour.Whiletheformerisoperationallytranslatableintothelatterasdiscussedin6.1,theverytranslationof,say,theprogrammingexamplesintheprecedingsectionswouldrevealthesigni canceofthesessionstructureforabstractionconcerns.Inparticular,anysuchtranslationshouldusemultiplenamesforactionsbelongingtoasinglesession,whichdam-agestheclarityandreadabilityoftheprogram.Wenotethatwearefarfromclaimingthattheproposedframeworkwouldformthesolestratumforhigh-levelcommunication-basedprogramming:abstractionconcernsfordistributedcomput-ingaresodiversethatanysingleframeworkcannotmeetallpurposes.Howeverwedobelievethattheproposedconstructs(withpossiblevariations)wouldo erabasicandusefulbuildingblockforcommunication-basedprogramming,especiallywhenconcernedcommunicationbehaviourstendtobecomecomplex.(2)Fromtheviewpointoftypedisciplines,onenotablepointofthepresentnotionoftypeswouldbethatwell-typedprogramsinthepresenttypingsystemareingeneralill-sorted(inthesenseof[21])whentheyareregardedas-terms,sincethesamechannelmaybeusedforcarryingvaluesofdi erentsortsatdi erentoccasions.Thisisinasharpcontrastwithmosttypedisciplinesfor-calculusand-calculus-basedprogramminglanguagesinliterature.Anexceptionisthetypingsystemformonadic-calculuspresentedin[41],where,asinthepresentsetting,the incorporationofsequencinginformationintypesallowscertainill-sortedprocessestobewell-typed.Apartfromanotabledi erenceinmotivation,amaintechnicaldi erenceisthattherulesin[41]arenotsyntax-directedsothatthetypeinferencealgorithmmaynotbeasstraightforwardasinthepresentsetting;atthesametime,thetypedisciplinein[41]guaranteesamuchstrongerbehaviouralproperty.Wealsonotethatatypingsystemforill-sortedprocessesisalsostudiedin[17]inthecontextofpolymorphism.Inanothercontext,weobservethatonenotablefeatureofthepresenttypingsystemisthelinearusageofchannelsitimposesonprograms.Inthiscontext,theprecedingstudyonlinearityin-calculussuchas[11,16]o erstheclari cationofthedeterministiccharacterofinteractionatchannels(noticeinteractionatnamesisstillnon-deterministicingeneral).Also[]and[Catruleshavesomeresemblancetotherulesforlinearnamecommunicationpresentedin[11,16].Regardingtheseandotherworksontypesfor-calculus,wenotethatvariouscasesofredundantcodesintranslationmentionedin6.1aboveoftenconcerncertain xedwaysofusingnamesinprocesses,whichwouldbeamenabletotype-basedanalysis.Finallyoneofthemostimportanttopicswhichwecouldnottouchinthepresentpaperisthedevelopmentofreasoningprinciplesbasedontheproposedstructuringmethod.NoticethetypedisciplineinSection5alreadygivesonesimple,thoughuseful,example.Howeveritisyettobestudiedwhetherreasoningmethodsondeeperpropertiesofprograms(cf.[1,4,10,14,19,24]),whicharebothmathematicallywell-foundedandareapplicabletoconspicuouspracticalsituations,canbedevelopedornot.Wewishtotouchonthistopicinourfuturestudy.Acknowledgements.Wesincerelythankthreereviewersfortheirconstructivecom-ments.DiscussionswithSimonGay,LusLopes,BenjaminPierce,KakuTakeuchiandNobukoYoshidahavebeenbene cial,forwhichwearegrateful.Wealsothankthelasttwoforo eringcriticismsonanearlierversionofthepaper.VascoVasconcelosispartiallysupportedbyProjectPRAXIS/2/2.1/MAT/46/94.References[1]S.Abramsky,S.Gay,andR.Nagarajan,InteractionCategoriesandFoundationsofTypedCon-currentComputing.DeductiveProgramDesign,Springer-Verlag,1995.[2]G.Agha.Actors:AModelofConcurrentComputationinDistributedSystems.MITPress,1986.[3]P.America.OperationalSemanticsofaParallelObject-OrientedLanguage.POPL'86,ACMPress,[4]P.AmericaandF.deBoer.ReasoningaboutDynamicallyEvolvingProcessStructures.FormalAspectsofComputing,94:269{316,1994.[5]G.BerryandG.Boudol.Thechemicalabstractmachine.,96:217{248,1992.[6]B.Courcelle.Fundamentalpropertiesofin nitetrees.,25:95{169,1983.[7]C.FournetandG.Gonthier.There exivechemicalabstractmachineandthejoin-calculus.POPL'96,pp.372{385,ACMPress,1996.[8]Gay,S.,ASortInferenceAlgorithmforthePolyadic-Calculus.POPL'93,ACMPress,1993.[9]C.A.R.Hoare.Communicatingsequentialprocesses.CACM,21(8):667{677,1978.[10]C.A.R.Hoare.CommunicatingSequentialProcesses.PrenticeHall,1995.[11]K.Honda.Composingprocesses.POPL'96,pp.344{357,ACMPress,1996.[12]K.Honda,V.Vasconcelos,andM.Kubo.Languageprimitivesandtypedisciplinesforstructuredcommunication-basedprogramming.Fullversionofthispaper,inpreparation.[13]C.B.Jones.Process-AlgebraicFoundationsforanObject-BasedDesignNotation.UMCS-93-10-1,ComputerScienceDepartment,ManchesterUniversity,1993.[14]C.B.Jones.AccommodatingInterferenceintheFormalDesignofConcurrentObject-BasedPro-grams.FormalMethodsinSystemDesign,8(2):105-122,March1996[15]S.P.Jones,A.Gordon,andS.Finne.ConcurrentHaskell.POPL'96,pp.295{308,ACMPress, [16]N.Kobayashi,B.Pierce,andD.Turner.Linearityandthepi-calculus.POPL'96,pp.358{371,ACMPress,1996.[17]X.LiuandD.Walker.Apolymorphictypesystemforthepolyadicpi-calculus.CONCUR'95LNCS,Springer,1995.[18]L.Lopes,F.Silva,andV.Vasconcelos.Aframeworkforcompilingobjectcalculi.Inpreparation.[19]R.Milner.CommunicationandConcurrency.C.A.R.HoareSeriesEditor.PrenticeHall,1989.[20]R.Milner.Functionsasprocesses.,2(2):119{141,1992.[21]R.Milner,Polyadic-Calculus:atutorial.LogicandAlgebraofSpeci cation,Springer-Verlag,[22]R.Milner,J.Parrow,andD.Walker.Acalculusofmobileprocesses,PartsIandII.JournalofInformationandComputation,100:1{77,September1992.[23]R.MilnerandM.Tofte.TheDe nitionofStandardML.MITPress,1991.[24]H.R.NielsonandF.Nielson.Higher-orderconcurrentprogramswith nitecommunicationtopol-ogy.POPL'94.ACMPress,1994.[25]A.OhoriandK.Kato.Semanticsforcommunicationprimitivesinapolymorphiclanguage.POPL.ACMPress,1993.[26]A.Ohori.AcompilationmethodforML-stylepolymorphicrecordcalculi.POPL92,pp.154{165.ACMPress,1992.[27]B.PierceandD.Turner.Pict:Aprogramminglanguagebasedonthepi-calculus.CSCITechnicalReport476,IndianaUniversity,March1997.[28]B.Pierce,andD.Sangiorgi,Typingandsubtypingformobileprocesses.LICS'93,IEEE,pp.187{215,1993.[29]B.PierceandD.Sangiorgi,BehavioralEquivalenceinthePolymorphicPi-Calculus.POPL97ACMPress,1997.[30]J-H.Reppy.CML:Ahigher-orderconcurrentlanguage.PLDI91,pp.293{305.ACMPress,1991.[31]M.Muller,J.NiehrenandG.Smolka,TypedConcurrentProgrammingwithLogicVariables,tech-nicalreport,ProgrammingSystemsLab,UniversitatdesSaarlandes,January1998.[32]K.Takeuchi,K.Honda,andM.Kubo.Aninteraction-basedprogramminglanguageanditstypingsystem.PARLE'94,volume817of,pp.398{413.Springer-Verlag,July1994.[33]USGovernmentPrintingOce,WashingtonDC.TheAdaProgrammingLanguage,1983.[34]V.Vasconcelos.Typedconcurrentobjects.ECOOP'94,volume821of,pp.100{117.Springer-Verlag,1994.[35]V.VasconcelosandK.Honda,PrincipalTypingSchemeforPolyadic-Calculus.CONCUR'93Volume715of,pp.524-538,Springer-Verlag,1993.[36]V.VasconcelosandM.Tokoro.Atypingsystemforacalculusofobjects.1stISOTAS,volume742,pp.460{474.Springer-Verlag,November1993.[37]D.Walker,Objectsinthe-calculus.InformationandComputation,Vol.116,pp.253{271,1995.[38]Y.YokoteandM.Tokoro.ConcurrentprogramminginConcurrentSmalltalk.In[40].[39]A.Yonezawa,editor.ABCL,anObject-OrientedConcurrentSystem.MITPress,1990.[40]A.YonezawaandM.Tokoro,editors.Object-OrientedConcurrentProgramming.MITPress,1987.[41]N.Yoshida,GraphTypesforMonadicMobileProcesses.FST/TCS'16,volume1180ofpp.371{386,Springer-Verlag,1996.ThefullversionasLFCSTechnicalReport,ECS-LFCS-96-350,1996.

Related Contents


Next Show more