10.07.2015 Views

Algol 68 - ACM Digital Library

Algol 68 - ACM Digital Library

Algol 68 - ACM Digital Library

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

60 van Wijngaarden, et al.and so on; this is to be understood as(x >O[ l + x[ (x < OI 1 -x I i)).CASE-clauses, which define choices depending on an integer or on amode, are different in that the in-CASE-clause is further decomposed intounits. The general pattern is(---{---, .... ---I---) orcase --- in ---, ..., --- out --- esac.The choice may also be reiterated by use of ouse.In a choice-using-integral-clause (or ease-clause), the parts are simplyunits and there must be at least two of them; the choice among the unitsfollows their textual ordering.Example:proc void work, relax, enjoy;case int day; read (day); dayin work, work, work, work, work, relax, enjoyout print ((day, "is not in the week"))esac.In a choice-using-UNITED-clause (or conformity-clause), which testsmodes, each case-part-of-CHOICE is of the form (declarer identifier): unitor (declarer): unit. The mode specified by the declarer is compared withthe mode of the value under test; the identifier, if present, is availableinside the unit to access that value, with the full security of syntacticalmode checking. The 'UNITED' mode provides the required freedom for themode of the value under test; moreover, that 'UNITED' mode must containthe mode of each specification for, otherwise, the corresponding case-partof-CHOICEcould never be chosen.Example:'mode boy = struct (int age, real weight),• mode girl = struct (int age, real beauty);proc union (boy, girl) newborn;case newborn in(boy john): print (weight of john),(girl mary): print (beauty of mary)esac. }{The flowers that bloom in the spring,Tra la,Have nothing to do with the case.Mikado,W.S. Gilbert.}{The hierarchy of ranges in conditional-clauses is illustrated byifthen else JI I . I IALGOL <strong>68</strong> Revised Report 61and similarly for the other kinds of choice. Thus the nest and the environof the enquiry-clause remain valid over the in-CHOICE-clause and the out-CHOICE-clause. However, no transfer back from the in- or out-CHOICEclauseinto the enquiry-clause is possible, since the latter can contain nolabel-definitions (except within a closed-clause contained within it).}3.4.1. SyntaxA) CHOICE :: choice using boolean ; CASE.B) CASE :: choice using integral ; choice using UNITED.a) SOlD NESTI CHOICE elause{5D,551a,A341h,A349a} :CHOICE STYLE start{91a,-},SOlD NESTI chooser CHOICE STYLE clause{b},CHOICE STYLE finish{91e,-}.b) SOlD NESTI chooser choice using MODE STYLE clause{a,l} :MODE NESTI enquiry clause defining LAYER2{c,-},SOlD NESTI LAYER2 alternate choice using MODESTYLE clause{d}.c) MODE NESTI enquiry clause defining new DECSETY2{b,35g} :meek MODE NESTI new DECSETY2 series with DECSETY2{32b}.d) SOlD NEST2 alternate CHOICE STYLE clause{b} :SOlD NEST2 in CHOICE STYLE clause{e} ;where SOlD balances SOIDI and SOID2{32e},SOIDI NEST2 in CHOICE STYLE clause{e},SOLD2 NEST2 out CHOICE STYLE clause{l}.e) SOlD NEST2 in CHOICE STYLE clause{d} :CHOICE STYLE in[91b,-}, SOlD NEST2 in part of CHOICE{f,g,h}.f) SOlD NEST2 in part of choice using boolean{e} :SOlD NEST2 serial clause defining LAYER3{32a}.g) SOlD NEST2 in part of choice using integral{e} :SOlD NEST2 joined portrait{33b}.h) SOlD NEST2 in part of choice using UNITED{e,h} :SOlD NEST2 case part of choice using UNITED{i} ;where SOlD balances SOIDI and SOlD2{32e},SOIDI NEST2 case part of choice using UNITED{i},and also{94f} token,SOLD2 NEST2 in part of choice using UNITED{h}.i) SOlD NEST2 case part of choice using UNITED{h} :MOlD NEST2 LAYER3 specification defining LAYER3[j,k,-},where MOlD unites to UNITED{64b},SOlD NEST2 LAYER3 unit{32d}.{Here LAYER3 :: new MODE TAG ; new EMPTY.}j) MODE NEST3 specification defining new MODE TAG3{i} :NEST3 declarative defining new MODE TAG3{541e} brie[ pack,colon{94f} token.k) MOlD NEST3 specification defining new EMPTY{i} :formal MOll) NEST3 declarer{46b} brief pack, colon{94f} token.

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

Saved successfully!

Ooh no, something went wrong!