DeptofComputerScienceUniversityofEdinburghUKDeptofComputerScienceUniversityofLisbonPortugalDeptofComputerScienceChibaUniversityofCommerceJapan procedurecallThesituationmaybeillustratedinc ID: 402680
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.
LANGUAGEPRIMITIVESANDTYPEDISCIPLINEFORSTRUCTUREDCOMMUNICATION-BASEDPROGRAMMINGKOHEIHONDA,VASCOT.VASCONCELOS,ANDMAKOTOKUBOAbstract.Weintroducebasiclanguageconstructsandatypedisciplineasafoun-dationofstructuredcommunication-basedconcurrentprogramming.Theconstructs,whichareeasilytranslatableintothesummation-lessasynchronous-calculus,allowprogrammerstoorganiseprogramsasacombinationofmultiple owsof(possiblyunbounded)reciprocalinteractionsinasimpleandelegantway,subsumingthepre-cedingcommunicationprimitivessuchasmethodinvocationandrendez-vous.TheresultingsyntacticstructureisexploitedbyatypedisciplinealaML,whichoersahigh-leveltypeabstractionofinteractivebehavioursofprogramsaswellasguar-anteeingthecompatibilityofinteractionpatternsbetweenprocessesinawell-typedprogram.Afterpresentingtheformalsemantics,theuseoflanguageconstructsisillustratedthroughexamples,andthebasicsyntacticresultsofthetypedisciplineareestablished.Implementationconcernsarealsoaddressed.IntroductionRecently,signicanceofprogrammingpracticebasedoncommunicationamongpro-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,variouscommunicationprimitiveshavebeenoered(suchassynchronous/asynchronousmessagepassing,remoteprocedurecall,method-callandrendez-vous),andthedescriptionofcommunicationbehaviourisdonebycombin-ingtheseprimitives.Whatweobserveintheseprimitivesisthat,whiletheydoexpressone-timeinteractionbetweenprocesses,thereisnoconstructtostructureaseriesofreciprocalinteractionsbetweentwopartiesassuch.Thatis,theonlywaytorepresentaseriesofcommunicationsfollowingacertainscenario(thinkofinteractionsbetweenaleserveranditsclient)istodescribethemasacollectionofdistinct,unrelatedin-teractions.Inapplicationsbasedoncomplexinteractionsamongconcurrentprocesses,whichareappearingmoreandmoreinthesedays,thelackofstructuringmethodswouldresultinlowreadabilityandcarelessbugsinnalprograms,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,readabilityorveriability,sothatthenotionofstructuredprogrammingwasproposedin1970's.Inpresentdays,havingthelanguageconstructsforstructuredprogrammingisanorminimperativelanguages.Suchacomparisonraisesthequestionastowhetherwecanhaveasimilarstructuringmethodinthecontextofcommunication-basedconcurrentprogramming.Itsobjectiveistooerabasicmeanstodescribecomplexinteractionbehaviourswithclarityanddisciplineatthehigh-levelofabstraction,togetherwithaformalbasisforverication.Itskeyelementswould,aboveall,consistof(1)thebasiccommunicationprimitives(correspondingtoassignmentandarithmeticoperationsintheimperativesetting),and(2)thestructuringconstructstocombinethem(correspondingto\if-then-else"and\while").Vericationmethodologiesontheirbasisshouldthenbedeveloped.Thepresentpaperproposesstructuringprimitivesandtheaccompanyingtypedisci-pline,asabasicstructuringmethodforcommunication-basedconcurrentprogramming.Theproposedconstructshaveasimpleoperationalsemantics,andvariouscommuni-cationpatterns,includingthoseoftheconventionalprimitivesaswellasthosewhichgobeyondthem,arerepresentableastheircombinationwithclarityandrigoratthehigh-levelofabstraction.Thetypedisciplineplaysafundamentalrole,guaranteeingcompatibilityofinteractionpatternsamongprocessesviaatypeinferencealgorithminthelineofML[23].Concretelyourproposalconsistsofthefollowingkeyideas.Abasicstructuringconceptforcommunication-basedprogramming,calledsessionAsessionisachainofdyadicinteractionswhosecollectionconstitutesaprogram.Asessionisdesignatedbyaprivateportcalledchannel,throughwhichinterac-tionsbelongingtothatsessionareperformed.Channelsformadistinctsyntacticdomain;itsdierentiationfromtheusualportnamesisabasicdesigndecisionwetaketomakethelogicalstructureofprogramsexplicit.Otherthansession,thestandardstructuringconstructsforconcurrentprogramming,parallelcompo-sitionnamehidingconditionalandrecursionareprovided.Inparticularthecombinationofrecursionandsessionallowstheexpressionofunboundedthreadofinteractionsasasingleabstractionunit.Threebasiccommunicationprimitives,valuepassinglabelbranching,anddelega-tion.Therstisthestandardsynchronousmessagepassingasfoundine.g.CSP-calculus.Thesecondisapuriedformofmethodinvocation,deprivedofvaluepassing.Thethirdisforpassingachanneltoanotherprocess,thusallowingaprogrammertodynamicallydistributeasinglesessionamongmultipleprocessesinawell-structuredway.Togetherwiththesessionstructure,thecombinationoftheseprimitivesallowsthe exibledescriptionofcomplexcommunicationstruc-tureswithclarityanddiscipline.basictypedisciplineforthecommunicationprimitives,asanindispensableele-mentofthestructuringmethod.Thetypabilityofaprogramensurestwopossiblycommunicatingprocessesalwaysowncompatiblecommunicationpatterns.Forex-ample,aproceduralcallhasapatternofoutput-inputfromthecaller'sviewpoint;thenthecalleeshouldhaveacommunicationpatternofinput-output.Becausein-compatibilityofinteractionpatternsbetweenprocesseswouldbeoneofthemainreasonsforbugsincommunication-basedprogramming,webelievesuchatype disciplinehasimportantpragmaticsignicance.Thederivedtypegiveshigh-levelabstractionofinteractivebehavioursofaprogram.Becausecommunicationbetweenprocessesoverthenetworkcanbedonebetweenmod-uleswrittenindierentprogramminglanguages,theproposedcommunicationconstructsmayaswellbeusedbyembeddingtheminvariousprogramminglanguages;howeverforsimplicitywepresentthemasaself-containedsmallprogramminglanguage,whichhasbeenstrippedtothebarestminimumnecessaryforexplanationofitsnovelfea-tures.Usingthelanguage,thebasicconceptoftheproposedconstructsisillustratedthroughprogrammingexamples.Theyshowhowextantcommunicationprimitivessuchasremoteprocedural-callandmethodinvocationcanbeconciselyexpressedasses-sionsofspecicpatterns(hencewithspecictypeabstractions).Theyalsoshowhowsessionscanrepresentthosecommunicationstructureswhichdonotconformtothepre-cedingprimitivesbutwhichwouldnaturallyariseinpractice.Thissuggeststhatthesession-basedprogramorganisationmayconstituteasynthesisofanumberoffamiliaraswellasnewprogrammingideasconcerningcommunication.Wealsoshowthepro-posedconstructscanbesimplytranslatableintotheasynchronouspolyadicwithbranching[36].Thissuggeststhefeasibilityofimplementationindistributedenvi-ronment.Yetmuchremainstobestudiedconcerningtheproposedstructuringmethod,includingtheecientimplementationoftheconstructsandtheaccompanyingreasoningprinciples.SeeSection6formorediscussions.Thetechnicalcontentofthepresentpaperisdevelopedonthebasisoftheprecedingproposal[32]duetoKakuTakeuchiandthepresentauthors.Themaincontributionsofthepresentproposalincomparisonwith[32]are:thegeneralisationofsessionstructurebydelegationandrecursivesessions,whichdenitelyenlargestheapplicabilityoftheproposedstructuringmethod;thetypingsystemincorporatingthesenovelconcepts;rep-resentationofconventionalcommunicationprimitivesbythestructuringconstructs;andbasicprogrammingexampleswhichshowhowtheconstructs,inparticularthroughtheuseoftheabovementionednovelfeatures,canlucidlyrepresentcomplexcommunicationstructureswhichwouldnotbeamenabletoconventionalcommunicationprimitives.Intherestofthepaper,Section2introducesthelanguageprimitivesandtheirop-erationalsemantics.Section3illustrateshowtheprimitivesallowcleanrepresentationofextantcommunicationprimitives.Section4showshowtheprimitivescanrepresentthoseinteractionstructuresbeyondthoseoftheconventionalcommunicationprimitivesthroughkeyprogrammingexamples.Section5presentsthetypingsystemandestab-lishesthebasicsyntacticresults.Section6concludeswithdiscussionsontheimplemen-tationconcerns,relatedworksandfurtherissues.SyntaxandOperationalSemantics2.1.BasicConcepts.Thecentralideainthepresentstructuringmethodisasion.Asessionisaseriesofreciprocalinteractionsbetweentwoparties,possiblywithbranchingandrecursion,andservesasaunitofabstractionfordescribinginteraction.Communicationsbelongingtoasessionaredoneviaaportspecictothatsession,calledchannel.Afreshchannelisgeneratedwheninitiatingeachsession,fortheuseincom-municationsinthesession.Weusethefollowingsyntaxfortheinitiationofasession.initiationofsessionrstrequests,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.Identiersin~shouldbepairwisedistinct.Wecanusereplication(orasinglerecursion)toachievethesameeect,butmultiplerecursionispreferableforwell-structuredprograms.Thisnishestheintroductionofalllanguageconstructsweshalluseinthispaper.Wegiveasimpleexampleofaprogram.![1];];x+1];Therstprocessreceivesarequestforanewsessionvia,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,denedinthestandardway,arerespectivelydenotedbyfn(fc(fv(andfpv().Thealpha-equalityiswritten.Wealsosetfu(=fc((fn(P).Processeswithoutfreevariablesorfreechannelsarecalledprograms2.3.OperationalSemantics.Fortheconcisedenitionoftheoperationalsemanticsofthelanguageconstructs,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.Notewedonotallowreductionundervariouscommunicationprexes,asinstandardprocesscalculi.Asanexample,thesimpleprogramin2.1hasthefollowingreduction(belowandhenceforthweomittrailinginactions).![1];];x+1]![1];];x+1]))x+1]))=y]:Observehowinteractionproceedsinalock-stepfashion.Thisisduetothesynchronousformofthepresentcommunicationprimitives.RepresentingCommunication(1)ExtantCommunicationPrimitivesThissectiondiscusseshowstructuringprimitivescanrepresentwitheasethecommu-nicationpatternsofconventionalcommunicationprimitiveswhichhavebeeninuseinprogramminglanguages.Theyshowhowwecanunderstandtheextantcommunicationpatternsasaxedwayofcombiningtheproposedprimitives.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[[x1]inreturnreturnxy])Hereandhenceforthwewrite,orasequenceofsuchequations,forthedeclarationpartofrecursion,leavingthebodypartimplicit.Thisexampleimplementsthestandardrecursivealgorithmforthefactorialfunction.[5]wouldgiveitsclientprocess.Thecommunicationpatternsbasedoncall-returnareeasilyrepresentablebythecombinationofrequest/acceptandsend/receive.Werstshowthemappingofthecaller.Below[[]]denotestheinductivemappingintothestructuringprimitives..x=calla[~e]inP]]def=requesta(k)ink![~~P]]:Naturallyweassumeischosenfresh.Thebasicscenarioisthatacallerrstinitiatesthesession,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[[x1];;xy])Noticehowtheusageofanddierentiatesthetwocontextsofcommunication.Ifwecomposethetranslationoffactorialwiththatofitsuser,wehavethereduction:Fact[ct[y=callf[3]Fact[ct[P]][6Inthisway,thesemanticsofthesynchronouscall-returnisgivenbythatofthestruc-turingprimitivesviathetranslation.Someobservationsfollow.(1)Thesignicanceofthespecicnotationsforcall-returnwouldlieinthedeclarationoftheassumedxedcommunicationpattern,whichwouldenhancereadabilityandhelpverication.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,inadditiontothexedpatternofinput-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;whereagivesanobjectidentier,;:::;larelabels(allpairwisedistinct)withformalparameters~,andgivesthecodecorrespondingtoeach.Thereturnaction,writtenne],mayoccurineachasnecessary.Acallerthenbecomes:a:lle]inPa:lle];P:Theleft-handsidedenotesaprocesswhichinvokestheobjectwithamethodtogetherwitharguments~,then,receivingtheanswer,assignstheresultto,andnallyexecutesthecontinuation.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.Intherstequation,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.Thespecicnotationhoweverhasaroleofdeclaringthexedcommunicationpatternandsaveskey-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].Section6givesabriefdiscussiononthesignicanceofspecicnotationsforthesexedcommunicationpatternsinlanguagedesign.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(weomitsuchdetailsasvericationofthecodeetc.),thenoersthreechoices,,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.Thefollowingrenementmakesthisredundancyunnecessary. 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,themaindierenceliesinthattheprocessisstillwithinthesamesessionevenafterrecurringtothewaitingmode,afterprocessingeachrequest:onceauserestablishesthesessionandenterstheusercode,shecanrequestvariousservicesasmanytimesasshelikes.Toexitfromthisloop,thebranchisintroduced.Thisexampleshowshowrecursionwithinasessionallowsa exibledescriptionofinteractivebehaviourwhichgoesbeyondtherecursioninusualobjects(whereeachsessionconsistsofaxednumberofinteractions).Itisnotablethattheunboundedsessionownsarigoroussyntacticstructuresoastoallowtypeabstraction,seeSection5.Unboundedinteractionswithaxedpatternnaturallyariseinpractice,e.g.interactionsbetweenaleserveranditsclient.Webelieverecursionwithinasessioncanbeeectivelyusedforvariedprogrammingpractice.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;ble;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,forexamplealeserverwithge-ographicallydistributedsitesoraserverwithmultipleserviceseachtobeprocessedbyadierentsub-server.(2)Akeyfactoroftheabovecodeisthataclientdoesnothavetobeconsciousofthedelegationwhichtakesplaceontheserver'sside:thatis,aclientprogramcanbewrittenasifitisinteractingwithasingleentity,forexampleasfollows.ws.myId];sfsorry:[]welcome:gObservethat,betweentheinitialandthenextsendingoperation,theinteractiontakesplaceontheserver'sside:howevertheclientprocessdoesnothavetobeconsciousoftheevent.Thisshowshowdelegationenablesdistributionofcomputationwhilemaintainingthetransparencyofthenamespace.(3)Ifwealloweachftp-threadtobedynamicallygenerated,wecanuseparallelcom-positiontothesameeect,justastheuseof\fork"topassprocessresourcesinUNIX.Whilethisschemehasalimitationinthatwecannotsendachanneltoanalreadyrunningprocess,itoersanotherprogrammingmethodtorealise exible,dynamiccommunicationstructures.Wealsoobservethattheuseoforthe\fork"mentionedabove,wouldresultincomplexlywovensequencesofinter-actions,whichwouldbecomemoreerror-pronethanwithout.Insuchsituations,thetypedisciplinediscussedinthenextsectionwouldbecomeanindispensabletoolforprogramming,wherewecanalgorithmicallyverifyifaprogramhascoherentcom-municationstructureand,inparticular,ifitcontainsinteractionerrors.TheTypeDiscipline5.1.Preliminaries.Thepresentstructuringmethodallowsthecleardescriptionofcomplexinteractionstructuresbeyondconventionalcommunicationprimitives.Themorecomplextheinteractionbecomes,however,themoredicultitwouldbetocapturethewholeinteractivebehaviourandtowritecorrectprograms.Thetypedisciplineweshalldiscussinthissectiongivesasimplesolutiontotheseissuesatabasiclevel.Werstintroducethebasicnotionsconcerningtypes,includingdualityontypeswhichrepresentscomplementarityofinteractions.Denition5.1(Types)Giventypevariablest;t)andsortvariabless;ssortsS;S)andtypes;;:::)aredenedbythefollowinggrammar.bool ~S];j#[];j&fl1:1;:::;ln:ngj1j?j"[~S];j"[];jf where,foratypeinwhichdoesnotoccur,wedene ,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)isanitepartialmapfromnamesandvariablestosorts(resp.fromchannelstotypes,resp.fromprocessvariablestothesequencesofsortsandtypes).Welet(resp.,resp.)rangeoversortings(resp.typings,resp.bases).Weregardtypesandsortsasrepresentingthecorrespondingregulartreesinthestandardway[6],andconsidertheirequalityintermsofsuchrepresentation.Asortofform representstwocomplementarystructuresofinteractionwhichareassociatedwithaname(onedenotingthebehaviourstartingwith,anotherthatwhichstartswith),whileatypegivestheabstractionofinteractiontobedonethroughachannel.Theco-typeofagiventypedenotesthecomplementarybehaviouroftheoriginaltype.Note holdswhenever isdened.Letusgiveabriefdescriptionofeachformoftypes.Thetypee~S];representsthebehaviourofrstinputtingvaluesofsorts,thendoestheactionsoftypee];representsthesimilarbehaviour,whichstartswiththechannelinput(catch)instead..~S];andd];aredualoff~S];andd];,sendingvaluesinteadofreceiving.showsthebranchingbehaviour:itwaitswithoptions,andbehavesastype-thactionisselected(externalchoice).thenrepresentsthebehaviourwhichwouldselectoneofandthenbehavesasaccordingtotheselected(internalchoice).representstheinaction,actingastheunitofsequentialcomposition.denotesarecursivebehaviour,whichrepresentsthebehaviourofstartdoingand,whenisencountered,recurstoagain.Finallyisaspecictypeindicatingthatnofurtherconnectionispossibleatagivenname.Thefollowingpartialalgebraonthesetoftypings,cf.[11],playsakeyroleinourtypingsystem.Denition5.2(Typealgebra)Typingsandcompatible,writtenif )foralldom(dom().When,thecompositionofand,written,isgivenasatypingsuchthat()is(1),ifdom(dom();(2)),ifdom(dom(mod)forand(3)undenedotherwise.Compatibilitymeanseachcommonchannelisassociatedwithcomplementarybe-haviours,thusensuringtheinteractionontorunwithouterrors.Whencomposed,thetypeforbecomes,preventingfurtherconnectionat(notehasnoco-type).Onecancheckthepartialoperationispartiallycommutativeandassociative.5.2.TypingSystem.Themainsequentofourtypingsystemhasaform;whichreads:\undertheenvironment;,aprocesshasatyping."Sortingspeciesprotocolsatthefreenamesof,whiletypingspecies'sbehaviouratitsfreechannels.Whenisaprogram,andbecomebothempty.Givenatypingorasorting,say,writefors:pgtogetherwiththeconditionthatdom();andfortheresultoftakingo:()fromif( isdened(ifnotwetakeitself).Alsoassumegiventheevidentinferencerulesforarithmeticandbooleanexpressions,whosesequenthastheform,enjoyingthestandardpropertiessuchase.Sandimplyc.S.Themaindenitionofthissectionfollows.Denition5.3(Basictypingsystem)ThetypingsystemisdenedbytheaxiomsandrulesinFigure1,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").Itdiersfromvarioussortingdisciplinesinthatachannelisingeneralill-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,whichextractstheprincipaltypeofagivenprocessiitistypable.Itshouldbenotedthatsimplicityandtractabilityoftypingrulesdonotmeanthattheobtainabletypeinformationisuninteresting:theresultingtypeabstractionrichlyrepresentstheinteractivebehaviourofprograms,aslaterexamplesexhibit.Belowwebrie ysummarisethefundamentalsyntacticpropertiesofthetypingsystem.Weneedthefollowingnotion:aprocessisaprexedprocesswithsubject(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.Weomitthenalfromthetype,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.Asanalexample,theftpserverofExample4.3isgiventhefollowingtypeatitsprincipalname:e:natnatggThisexampleshowsthatthethrow/catchactionisabstractedawayinthetypewithrespecttotheuser(butnotinthetypewithrespecttothethread,whichweomit)sothattheusercaninteractwithoutconcerninghimselfwiththedelegationoccurringontheother'sside.Intheseways,notonlythetypedisciplineoersthecorrectnessvericationofprogramsatabasiclevel,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].Tondtheeective,well-foundedoptimisationmethodsinthislinewouldbeafruitfulsubjectofstudy(see6.2below).(3)Theencodingtranslatesthetypableprogramsintowell-sortedTCOcodes.Itisanintriguingquestionhowwecancapture,inapreciseway,thewell-typednessoftheoriginalcodeatthelevelofTCO(thisquestionwasoriginallyposedbySimonGayforaslightlydierentkindoftranslation). 6.2.RelatedWorksandFurtherIssues.Inthefollowing,comparisonswithafewrelatedworksaregivenalongwithsomeofthesignicantfurtherissues.First,inthecontextofconventionalconcurrentprogramminglanguages,thekeydepartureoftheproposedframeworkliesinthatthesessionstructureallowsustoformanarbitrarycomplexinteractionpatternasaunitofabstraction,ratherthanbeingrestrictedtoaxedrepertoire.ExamplesinSection4showhowthisfeatureresultsincleandescriptionofcomplexcommunicationbehaviourswhichmaynotbeeasytoexpressinconventionallanguages.Forexample,ifweuse,fordescribingthoseexamples,so-calledconcurrentobject-orientedlanguages[40],whoseprogrammingconceptbasedonobjectsandtheirinteractionisproximatetothepresentone,weneedtodivideeachseriesofinteractionsintomultiplechunksofindependentcommunications,which,togetherwiththenestingofmethodinvocations,wouldmaketheresultingprogramshardtounderstand.Theexplicittreatmentofsessionalsoenablesthetype-basedvericationofcompatibilityofcommunicationpatterns,whichwouldfacilitatethewritingofcorrectcommunication-basedprogramsatanelementarylevel.Inspiteoftheseobservations,webelievethatvariouscommunicationprimitivesinexistingprogramminglanguages,suchasobject-invocationandRPC,wouldnotdimin-ishtheirsignicanceevenwhenthepresentprimitivesareincorporated.Wealreadydiscussedhowtheywouldbeusefulfordeclaringxedcommunicationpatterns,aswellasforsavingkeystrokes(inparticulartheprimitivesforsimplemessagepassingwouldbetterbegivenamonglanguageconstructssincetheirdescriptioninthestructuringprimitivesis,ifeasy,roundabout).Noticewecanstillmaintainthesametypedisciplinebyregardingtheseconstructsasstandingforcombinationofstructuringprimitives,aswedidinSection3.Inanothervein,thecommunicationstructureswhichwecanextractfromsuchdeclarationwouldgiveusefulinformationforperformingoptimisation.Secondly,regardingchannelsasportnamesusedinaspecicway,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,whichisusedinmostworksinthiseld,isasubsystemofthelanguageconstructsaspre-sentedinthispaper,byrepresentingpolyadicsynchronousnamesending/receptionbythecombinationsofrequest/data-sendingandaccept/data-reception,respec-tively.Wealreadynotedthatthereisansimpleencodingintheconversedirection;Thusthesheerexpressivenessdoesnotchange.(2)Inspiteoftheabovepoint,thereisabasicdierencebetweenthe-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);butitdoesleadtotheclaricationofcommunica-tionstructuresinprograms,whichenhancesreadabilityofprogramsandmakesitpossibletostaticallydetectincompatibilityincommunicationpatterns.Withrespecttothesecondpoint,itwouldbeinterestingtostudyhowwecanloosenthepresentconstraintonchannelsinmeaningfulwayswhilestillkeepingthebenetofthepresentframework,referringtovariouspossibilitiesasfoundin-calculi,aswellasconsideringpracticalconcerns.Thirdly,theeldofresearchwhichiscloselyrelatedtothepresentworkisthestudyofvarioustypedprogramminglanguagesbasedon-calculi[7,27,34]andoftypesfor-calculi(seeforexample[21,8,28,29,16,17,31,35,41]).Typesimposevariousconstraintsonthesyntaxofprocesses,andthusrestraintheprocessestohaveonly\good"interactivebehaviours.Variednotionsoftypeshavebeenstudiedinthecontext-calculusandthenhavebeenappliedtothesettingofprogramminglanguagesbased-calculi.Comparisonswiththeworksinthiseldmaybedonefromtwodistinctviewpoints,languagedesignconcernsandnotionsoftypes.(1)Fromtheviewpointoflanguagedesign,Pictandother-calculus-basedlanguagesusetheprimitivesof(polyadic)asynchronous-calculusoritsvariantsasthebasiclanguageconstructs,andbuildfurtherlayersofabstractionontheirbasis.Thepresentproposaldiersinthatitincorporatesthesession-basedstructureasafun-damentalstratumforprogramming,ratherthanrelyingonchainsofdirectnamepassingfordescribingcommunicationbehaviour.Whiletheformerisoperationallytranslatableintothelatterasdiscussedin6.1,theverytranslationof,say,theprogrammingexamplesintheprecedingsectionswouldrevealthesignicanceofthesessionstructureforabstractionconcerns.Inparticular,anysuchtranslationshouldusemultiplenamesforactionsbelongingtoasinglesession,whichdam-agestheclarityandreadabilityoftheprogram.Wenotethatwearefarfromclaimingthattheproposedframeworkwouldformthesolestratumforhigh-levelcommunication-basedprogramming:abstractionconcernsfordistributedcomput-ingaresodiversethatanysingleframeworkcannotmeetallpurposes.Howeverwedobelievethattheproposedconstructs(withpossiblevariations)wouldoerabasicandusefulbuildingblockforcommunication-basedprogramming,especiallywhenconcernedcommunicationbehaviourstendtobecomecomplex.(2)Fromtheviewpointoftypedisciplines,onenotablepointofthepresentnotionoftypeswouldbethatwell-typedprogramsinthepresenttypingsystemareingeneralill-sorted(inthesenseof[21])whentheyareregardedas-terms,sincethesamechannelmaybeusedforcarryingvaluesofdierentsortsatdierentoccasions.Thisisinasharpcontrastwithmosttypedisciplinesfor-calculusand-calculus-basedprogramminglanguagesinliterature.Anexceptionisthetypingsystemformonadic-calculuspresentedin[41],where,asinthepresentsetting,the incorporationofsequencinginformationintypesallowscertainill-sortedprocessestobewell-typed.Apartfromanotabledierenceinmotivation,amaintechnicaldierenceisthattherulesin[41]arenotsyntax-directedsothatthetypeinferencealgorithmmaynotbeasstraightforwardasinthepresentsetting;atthesametime,thetypedisciplinein[41]guaranteesamuchstrongerbehaviouralproperty.Wealsonotethatatypingsystemforill-sortedprocessesisalsostudiedin[17]inthecontextofpolymorphism.Inanothercontext,weobservethatonenotablefeatureofthepresenttypingsystemisthelinearusageofchannelsitimposesonprograms.Inthiscontext,theprecedingstudyonlinearityin-calculussuchas[11,16]oerstheclaricationofthedeterministiccharacterofinteractionatchannels(noticeinteractionatnamesisstillnon-deterministicingeneral).Also[]and[Catruleshavesomeresemblancetotherulesforlinearnamecommunicationpresentedin[11,16].Regardingtheseandotherworksontypesfor-calculus,wenotethatvariouscasesofredundantcodesintranslationmentionedin6.1aboveoftenconcerncertainxedwaysofusingnamesinprocesses,whichwouldbeamenabletotype-basedanalysis.Finallyoneofthemostimportanttopicswhichwecouldnottouchinthepresentpaperisthedevelopmentofreasoningprinciplesbasedontheproposedstructuringmethod.NoticethetypedisciplineinSection5alreadygivesonesimple,thoughuseful,example.Howeveritisyettobestudiedwhetherreasoningmethodsondeeperpropertiesofprograms(cf.[1,4,10,14,19,24]),whicharebothmathematicallywell-foundedandareapplicabletoconspicuouspracticalsituations,canbedevelopedornot.Wewishtotouchonthistopicinourfuturestudy.Acknowledgements.Wesincerelythankthreereviewersfortheirconstructivecom-ments.DiscussionswithSimonGay,LusLopes,BenjaminPierce,KakuTakeuchiandNobukoYoshidahavebeenbenecial,forwhichwearegrateful.Wealsothankthelasttwoforoeringcriticismsonanearlierversionofthepaper.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.Fundamentalpropertiesofinnitetrees.,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.LogicandAlgebraofSpecication,Springer-Verlag,[22]R.Milner,J.Parrow,andD.Walker.Acalculusofmobileprocesses,PartsIandII.JournalofInformationandComputation,100:1{77,September1992.[23]R.MilnerandM.Tofte.TheDenitionofStandardML.MITPress,1991.[24]H.R.NielsonandF.Nielson.Higher-orderconcurrentprogramswithnitecommunicationtopol-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.