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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

eforebeinginsertedintoatableoftypeTmustbefinit(V),init(V.A), 8610.2.FormalTypestates<br />

variablename.Ifthevariablenameisabasevariablewithnocomponents, V.Theresultingtypestateiscalledaformaltypestate.Aformaltypestate itisreplacedby*.Theargumentlist(*)canoptionallybeomitted. lookslikeatypestate,exceptthatweomitthebasevariablefromeach init(V.B)g.Whenwewritethedenition,weomitthearbitraryvariable argumentofeachattribute,turningitfromavariablenameintoaformal ThedenitionsaysthatthetypestateofanarbitraryvariableVoftypeR T:tableofRfinit(*),init(A),init(B)gkeys(A);<br />

eachformalvariablenamewiththegivenvariablename. inwhichthetypeofthearbitraryvariableisknown. finit(X.Y),init(X.Y.A),init(X.Y.B)g.YoucansubstituteX.Yinto intotheformaltypestateinthedenitionabove,<strong>and</strong>obtainthetypestate ponentsofanarbitraryelementofatable. Tosubstituteavariablenameintoaformaltypestatemeanstoprex Aformalvariablenameorformaltypestateisalwayswritteninacontext Forexample,ifvariablenameX.YhastypeR,thenyoucansubstituteX.Y Formalvariablenamesarealsousedinkeylists,wheretheydenotecom-<br />

attributes,noteverycombinationofattributesisvalid. Becauseofthemeaningofthe<strong>Hermes</strong>datatypes<strong>and</strong>themeaningofthe 10.3ValidTypestates thekey<strong>and</strong>obtainanactualkeyofX.Y.A.<br />

tionsasinvalid: Herearetheattributecompatibilityruleswhichdenecertaincombina-<br />

Ifinit(X)isnotpresent,nootherattributewithargumentXmay<br />

Ifcase(V,V.A)ispresent,thennootherattributecase(V,V.B) IfXhascomponents,<strong>and</strong>init(X)isnotpresent,thennootherattributewithanycomponentasargumentmaybepresent.Thisfollows<br />

havevalues. fromthefactthatcomponentsofstructuredvaluesonlyexistwhen bepresent.Thisfollowsfromthefactthatonlyinitvariablescan thestructuredvalueitselfexists.<br />

Ifcase(V,V.A)ispresent,thenV.A'scasetypestateattributesare Ifcase(V,V.A)isabsent,thennootherattributewithV.Aascomponentmaybepresent.Thisfollowsfromthefactthatyoucanaccess<br />

componentsofavariantonlywhentheyarerevealed. variantexistsatatime. ispresent.Thisfollowsfromthefactthatonlyonecomponentofa present.ThesearetheattributesobtainedbysubstitutingV.Ainto

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

Saved successfully!

Ooh no, something went wrong!