Hermes: A Tutorial and Reference Manual - Researcher - IBM
Hermes: A Tutorial and Reference Manual - Researcher - IBM
Hermes: A Tutorial and Reference Manual - Researcher - IBM
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
12611.9.PolymorphOperations<br />
positive(x.id),gt(x.id,y)g.Thenafterexecutingthestatement tateattributesincludingxare:finit(x),init(x.name),init(x.id), <strong>and</strong>avariablethatdoesnot. constraintwhichincludebothavariablethatoverlapsthesourcevariable thedestinationvariablewillbedropped. beuninitialized.Beforethewrapstatementtypestateanalysiswilldropany nordestinationcanbeconstant,<strong>and</strong>attributesotherthaninitinvolving Othertypestaterestrictionsapplyasforamovestatement:neithersource<br />
inalvalueofx,<strong>and</strong>whosewrappercontainsatypeofperson<strong>and</strong>a formaltypestateoffinit(*),init(name),init(id),positive(id)g. Theconstraintfgt(x.id,y)gwillbedropped. wrapxasy; thevalueofywillbeapolymorphwhosewrappedvalueistheorig-<br />
Forexample,supposethatvariablexisoftypeperson,<strong>and</strong>thetypes-<br />
Unwrap Thenewtypestateforywillbesimplyfinit(y)g.<br />
expectedbythedestinationvariable.Thesource(polymorph)variablemust thatthetype<strong>and</strong>typestateonthewrappermatchthetype<strong>and</strong>typestate <strong>and</strong>movesthevalueintoadestinationvariable.Aruntimecheckinsures Theunwrapstatementremovesawrappedvaluefromapolymorphvariable simple{statement ::=unwrapresult{variable<br />
expectedtypestateisspeciedbycodingaformaltypestatewithinthe beinitialized. Theexpectedtypeissimplythetypeofthedestinationvariable.The frompolymorph{expressionunwrapped{typestate<br />
unwrapstatement. type,orifthetypestateonthewrapperisnotatleastashighastheformal typestatespeciedontheunwrapstatement,thenaPolymorphMismatch exceptionisraised. Ifthetypeonthewrapperdoesnotmatchthedestinationvariable's<br />
attributesofthedestinationvariableotherthanthosedenedbytheformal typestatearedropped. above,wecodethestatement: nordestinationcanbeconstant,thesourcevariablebecomesuninitialized, movingthevalue.Thismayentaildiscardingsomeofthewrappedvalue. theunwrapstatement,thentheappropriateattributesaredroppedbefore Othertypestaterestrictionsapplyasforamovestatement:neithersource Forexample,assumethatimmediatelyafterthewrapstatementshown Ifthetypestateonthewrapperishigherthanthetypestatespeciedon<br />
unwrapxfromyfinit(*),init(id),positive(id)g;