Hermes: A Tutorial and Reference Manual - Researcher - IBM
Hermes: A Tutorial and Reference Manual - Researcher - IBM
Hermes: A Tutorial and Reference Manual - Researcher - IBM
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
fullycheckedfortype<strong>and</strong>typestateerrorsbeforebeinginstantiatedas Algol-likelanguages.<strong>Hermes</strong>programs,evenwhendynamicallybuilt,are likeLisp,Scheme,<strong>and</strong>APL,allowprogramsasrst-classvalues.<strong>Hermes</strong> combinestheexibilityoftheselanguageswiththestaticcheckingofthe processes([SYB87a,SYB87b,SY86]). 161.4.PuttingProcessesTogether<br />
oftypeprogram..(Note:thesyntaxcreateofexpressionisusedrather thancreate(expression)todistinguishprimitiveoperationsfromfunction calls.RememberthatfunctionnameslikeParms.GetProgramarevariables, whereascreateisnot.)Thecreateoperationinstantiatesanew(child) boundtotheinitializationportofthelterprocess. theprogramlibrarybyGetProgram.Theresultofcreateisanoutputport process.Thecodeofthechildprocessisgivenbythevalueoftheoper<strong>and</strong> tocreate.Inthiscase,thatwillbetheFilterprogram,obtainedfrom Tocreateanewprocess,youapplytheoperationcreateoftoavalue<br />
toobtaintheprogramfromthelibrary,<strong>and</strong>thenweapplytheoperation createoftothisprogram.Theonlydierenceisthatthistime,theprogramnameisnotaconstant,butmustbeextractedfromParms.ParmString.<br />
delimeter'/',asecondobtainsallcharacterstotheleftofthedelimiter, Wewillnotexplainthisextractionindetail|onestatementlocatesthe thethirdobtainsallcharacterstotherightofthedelimiter.Theoperationspositionof<strong>and</strong>everyofareexplainedindetailinsection2.6.<br />
Bothprocesses|client<strong>and</strong>lter|havenowbeencreated. Wecreatetheclientprocessinthesameway:rstwecallGetProgram<br />
ment,weneedtosupply3outputports,<strong>and</strong>astring.Fortwooftheoutput nowcalltheinitializationportsofthetwochildprocesses. string.Wewillreceivebackanoutputportconnectedtothelter'sinput programsyou'lleverwrite)beginwithreceiveParmsfromInit.Sowe port.WestorethisportasavariableCliToFil.InthecallClientstate-<br />
initialized,<strong>and</strong>theydependfortheirinitializationonreceivingacallfrom theirparent.Rememberthattheseprograms(<strong>and</strong>probablymostofthe ForFilter,weneedtosupplythePutLineoutputport,<strong>and</strong>aprex Thenewlycreatedprocessescannotdoanythingyet.Theyneedtobe<br />
ports|GetLine<strong>and</strong>GetProgram,wesupplytheportswhichweourselves sameservicewhichwecanaccess.Instead,wewanttogivetheclientthe portCliToFil|theoutputportwejustobtainedfromFilter,<strong>and</strong>which received.ButforPutLine,wedon'twanttogivetheclientaccesstothe isconnectedtoFilter'sinputport.Wealsohavetogivetheclientaparameterstring,sofornow,let'sjustsendanemptystring.Aftermaking<br />
ofintheeventthereisnodelimiter.Thesecondclauseh<strong>and</strong>lesanexceptionanticipatedbytheGetPrograminterface|namelythattherequestedlesaNotFoundexceptionwhichcanberaisedbytheoperationposition<br />
programisnotfoundinthelibrary.Thethirdclauseh<strong>and</strong>lesthebuiltinex- work. bothcalls,wearenished|thetwochildprocesseswillnowdoallthereal Wehavewrittenthreeexceptionh<strong>and</strong>lerclauses.Therstclausehan-