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.
whichtheoutputportconnects|calledthematchinginputporttype.The 241.5.Declarations<strong>and</strong>Denitions thecreateofstatement.ThedenitionGetProgramInterfacespecies thatprogramsreturnedbyGetProgramhavealreadybeenchecked. callmessagetype<strong>and</strong>typestaterequiredforsendingontheoutputportare determinedfromthatinputporttype. calling<strong>and</strong>calledprogramsareseparatelycompiled.Whencompilingthe caller,thecompilerchecksthattheentrytypestateholdsbeforethecall, <strong>and</strong>computestheexit<strong>and</strong>exceptiontypestatesusingtheinterface.When Anoutputportdenitionsimplyspeciesthetypeoftheinputportto<br />
theentrytypestate,<strong>and</strong>checksthatthecorrectexittypestateholdsatthe pointofareturnstatement. mustlooklike.Thencheckyourselfagainstthedenitiongiven: compilingthecalledprogram,thecompilerusestheinterfacetodeduce Theinterfacedenitionsmaketypestatecheckingpossibleeventhough SeeifyoucanworkoutforyourselfwhatthedenitionsmoduleFilter Filter:using(St<strong>and</strong>ard)definitions<br />
FilterOut:outportofFilterIn; FilterInterface:callmessage(<br />
enddefinitions FilterIn:inportofFilterInterfacefinit(PutLine),init(Prefix)g; Prefix:Charstring, ClientPutLine:PutLineOut) constant(PutLine,Prefix) exitffullg; PutLine:PutLineOut,<br />
usedinthesamecontexts,besuretodeclarethemasthesametype. theyaretreatedastwodierenttypes.Ifyouintendtwovariablestobe havethesamestructure|samecomponenttypes,sameexceptions,etc.| denedinSt<strong>and</strong>ard.St<strong>and</strong>ardrefersonlytopredenedtypes<strong>and</strong>types example,thatifyoudenetwodierentcallmessagetypeswhichhappento denedwithinitself. Summary:In<strong>Hermes</strong>,allbasevariablesmustbedeclared.Alluserdenedtypesmustbedenedinseparatemodules.Onlythenamesof<br />
visible.Youhavelearnedhowtowriteprocessheaders,declarations,<strong>and</strong> predenedtypes<strong>and</strong>oftypesdenedinimporteddenitionsmodulesare Note:<strong>Hermes</strong>usesnameequivalencefortypedenitions.Thismeans,for NoticethatFilterhastoimportSt<strong>and</strong>ard,sinceitusesatype(PutLineOut)<br />
putports,<strong>and</strong>callmessages.Youknowwhenyouneedtoputatypespec-<br />
ieronanexpression.Youhavelearnedthefollowingterminology:type specier,denitionsmodule,import,visible,predened,entrytypestate, denitionsmodules,<strong>and</strong>thesyntaxfortypedenitionsofinputports,out-<br />
theentireskeletonofthe<strong>Hermes</strong>language<strong>and</strong>canwrite<strong>and</strong>executeHer- exittypestate,checkedattribute,nameequivalence.Younowunderst<strong>and</strong>