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.

thereisnoselectedelement,aNotFoundexceptionisraised. VariantTypeFamily 11.7VariantOperations 11.<strong>Hermes</strong>Operations115<br />

Avariantisavaluewhichwillhaveoneofaxed,pre-speciedsetof type{construction ::=variantofenumeration{type(<br />

adierentcomponentnametodesignateeachdierenttypeofvalue.A types.Sincein<strong>Hermes</strong>,everyvariablenamehasexactlyonetype,weuse case{declaration ::=named{literal!component{declaration component{typestate )[case{declaration[,case{declaration]...]<br />

variantVcanbeeither initialized<strong>and</strong>revealed:exactlyonecomponenthasavalue.Thepro-<br />

initialized<strong>and</strong>hidden:exactlyonecomponentexists.Theprogram uninitialized:ithasnovalue<strong>and</strong>therearenotypestateattributes<br />

ponent<strong>and</strong>noother.Thetypestateisinit(V),case(V,V.X).There gramknowswhichcomponenthasavalue<strong>and</strong>canaccessthatcom-<br />

ponentisaccessible.Thetypestateisinit(V). doesn'tknowwhichcomponentexists<strong>and</strong>whichdonot,sonocom-<br />

involvingvariableV<br />

componentsareequal. thecasesofthevariant,<strong>and</strong>theenumerationtypeisthecasetype. thenamedliteralsofanenumerationtype.Thesenamedliteralsarecalled literalofthecasetype,acomponentname,componenttype,<strong>and</strong>aformal Twovariantsareequaliftheyhavethesamecase<strong>and</strong>iftheirexisting Thecomponentsofavarianttypeareinone-to-onecorrespondencewith Avarianttypedenitionspecies:(1)thecasetype,(2)foreachnamed maybeothertypestateattributesinvolvingvariableV.X.<br />

lower. casetypestate.Thecasetypestateisthetypestatethecomponentwillhave revealed,thetypestatemaybecomehigherthanthistypestate,butnever justbeforeitishidden<strong>and</strong>justafteritisrevealed.Whilethevariantis Thefollowingisanexampleofavarianttypedenition. id:charstring; lisptype:enumeration('nil','atom','pair');

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

Saved successfully!

Ooh no, something went wrong!