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.

notallowedonconstantcopies.Avariableholdingaconstantcopyisautomaticallymadeuninitializedwhencontrolleavesthescopeofthevariable.<br />

Thefollowingisanexampleoftheinspectstatement. inspectcharinstring begin where(char='X'<strong>and</strong>positionofchar>2) 11.<strong>Hermes</strong>Operations113<br />

tweentheinspectstatement<strong>and</strong>thesimilarstatementusingtheoperation the-element. mentasthevariableholdingtheconstantcopy.Notethedierencesbe-<br />

sionastheelementvariableofaselector,<strong>and</strong>(2)withintheinsertstate-<br />

c:=charinstringwhere(char='X'<strong>and</strong>positionofchar>2); endinspect; Notethedoubleuseofthevariablechar|(1)withinthewhereexpres-<br />

insertcopyofcharintostring2;<br />

copy.Itisillegaltoapplyinsertdirectlytocharbecauseitisconstant, operationcanbeappliedtoconstantcopiesbutnottoordinarycopies. butitislegaltoapplyinsertdirectlytoc.Theposition-of-element mentproducesaconstantcopy,whereasthe-elementproducesanordinary whereasthe-elementworksonlywithcopyabletypes.Theinspectstate-<br />

havebeenpreviouslydeclared.Theinspectstatementworksforalltypes, Thetypestateonentrytothemainclauseoftheinspectstatement Theinspectstatementintroducesadeclarationofchar,whereascmust insertcintostring2;<br />

normally. For-Inspect mainclause,exceptthattheinspectvariablebecomesuninitialized.Ifthe mainclausecannotexitnormally,thentheinspectstatementcannotexit fromtheinspectstatementisthesameasthetypestateonexitfromthe theinspectvariableisintheelementtypestate.Thetypestateonexit isthesameasthetypestatepriortotheinspectstatementexceptthat<br />

lectedsubsetofthetable.Thetablemustbeinitialized.Themainclause (theclausefollowinginspect)isexecutedonceforeachselectedelement. Avariablewiththesamenameastheelementvariableoftheselectorholds Thefor-inspectstatementiteratesovertheelementsofatableorase-<br />

compound{statement<br />

tothefor-inspectstatementisusedtodeterminetheselectedvalues; aconstantcopyoftheselectedelement.Thevalueofthetableonentry ::=forselectorinspect<br />

anychangestothetablemadefromwithintheiteratedclausewillnotaffectwhichvaluesareselected.Ifthetableisordered,theelementswillbe<br />

endfor [statement;]...

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

Saved successfully!

Ooh no, something went wrong!