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.

Inspect-polymorph willincludefinit(name)g.Componentnamewillbediscardedbeforemovingthewrappedvalueintox.Theresultingtypestatewillbefinit(x),<br />

Thetypeswillmatch,buttheformaltypestateinthewrapperofy 11.<strong>Hermes</strong>Operations127 init(x.id),positive(x.id)g. compound{statement ::=inspectdeclaration<br />

morphisconstant. ceptthatinsteadofmovingthewrappedvalue,aconstantcopyismade. Theinspect-polymorphstatementbehaveslikeanunwrapstatementex-<br />

Thisallowsthevalueofapolymorphtobeexamined,evenifthepoly-<br />

endinspect begin [statement;]... frompolymorph{expressioninspect{typestate<br />

whichwouldbelegalevenifthepolymorphywereconstant: Hereisanalternativeversionoftheunwrapstatementshownabove,<br />

wouldnotbeaccessible,sincethetypestateinsidethestatementwouldbe thatcomponentwouldnotbediscardedintheconstantcopyx,butit inspectx:personfromyfinit(*),init(id),positive(id)g<br />

operation. simplyfinit(y)init(x),init(x.id),positive(x.id)g. Assumingthatthewrappedvaluehadaninitializedcomponentname, TheexceptionPolymorphMismatchisraisedexactlyasforanunwrap endinspect; begin .../*statementsreferringtox*/<br />

Type morphwrapper.Thisisaninitializedvalueoftypepredefined!typeofvalue. Thetypeofoperationevaluatestothetypeinformationstoredinthepoly-<br />

Thevalueincludesthetypename,thedenitionsmoduledeningthetype name,<strong>and</strong>alltheimporteddenitionsmodules. Theoper<strong>and</strong>mustbeaninitializedpolymorph. secondary::=typeofsecondary Typestate secondary::=typestateofsecondary

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

Saved successfully!

Ooh no, something went wrong!