28.01.2015 Views

Hermes: A Tutorial and Reference Manual - Researcher - IBM

Hermes: A Tutorial and Reference Manual - Researcher - IBM

Hermes: A Tutorial and Reference Manual - Researcher - IBM

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

printfhasaccesstothesameconsole.Butifyou<strong>and</strong>IeachhaveaprogramliteraldenotingtheQuitDispatcherprogram,wewillstillnothave<br />

have.Aswestatedearlyinthetutorial,everyonewithastaticbindingto Don'tconfuseprogramliteralswithstaticbindings,which<strong>Hermes</strong>doesn't endprocess)) (AdapterQuit,BufferQuit,Parms.Quit); returnQuitCM; 2.AMiniatureSystem51<br />

literalisacompletelyseparateprogramwithacompletelyseparateset accesstothesameprocess.Ifweeachinstantiatetheprogram,we'llhave<br />

asaseparatemodule.Itevaluatestoaninitialized,checkedvalueoftype ofdeclarations.Theprogramliteralistreatedasifithadbeencompiled turedlanguages.Inblockstructuredlanguages,nestedprocedurescanre-<br />

fertovariablesintheouterprocedure.Thisisnottruehere.Aprogram twoseparateprocessesrunningthesamecode.Theonlywaywecanshare outputporttotheother. predefined!program. aprocessisifoneofusinstantiatestheprocess,<strong>and</strong>passesacopyofthe Don'tconfuseprogramliteralswithnestedproceduresinblockstruc-<br />

programtextappearsasaprogramliteralinseveralprograms.Youdon't wanttomaintainmultiplecopiesofthesameprogramliteral,incaseyou refertoitbynamewithinanotherprogram.Thisisconvenientifthesame wishtomodifytheprogram. Hereisthesamecodewiththeprogramliteraloutofline: linking(QuitDispatcher) ... Youmaywriteaprogramliteraloutofline,separatelycompileit,<strong>and</strong><br />

call(QuitDispOut#(createofprocessQuitDispatcher))<br />

Testyourselftryingtowritetheadapter<strong>and</strong>quitdispatcherprocesses. 2.8.2Adapter<strong>and</strong>QuitDispatcher whichappearsrightaftertheimportslistatthebeginningofthesource writinglinking(QuitDispatcher). module.Inthisexample,wemakethenameQuitDispatchervisibleby Anout-of-lineprogramnameismadevisiblebymeansofalinkinglist, (AdapterQuit,BufferQuit,Parms.Quit);<br />

Hereisthecode: process(Init:AdapterIn) Adapter:using(St<strong>and</strong>ard,Adapter,WMExternal,Quit) declare Put:PutLineIn;--PutLineservice Parms:AdapterInterface;--initializationcallmessage Get:GetProgramIn;--GetProgramservice Quit:QuitIn;--Quitservice

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!