-- Last edited by Mitchell, April 23, 1980 12:03 PMBEGINErrorCode: TYPE = {damagedSample, callingError, programError};SampleRec: TYPE = RECORD[val: Value, next: Sample];Sample: TYPE = REF SampleRec;RETURNS [inSet: BOOLEAN, setMinus: SampleSet];-- ERRORs: Problem[damagedSample]END.This is where a global description of the module goesCHANGE LOGChanged by: YourName: DateTimeDescriptionOfChangeRemoveSample: PROCEDURE[toBeRemoved: Sample, from: SampleSet]NewSampleSet: PROCEDURE RETURNS[nilSet: SampleSet];JGM-- FILE: CedarSampleImpl.mesa-- Last edited by Mitchell, April 23, 1980 3:19 PMDIRECTORYEXPORTS CedarSample =Problem: ERROR[reason: ErrorCode] = CODE;. . .END;BEGINEND;-- ERRORs: Problem[damagedSample]RETURNS [inSet: BOOLEAN, setMinus: SampleSet] =IF . . . THEN ERROR Problem[damagedSample];. . .END;RETURN [sample];ENDCASE => ERROR Bug;Bug: ERROR = CODE;BEGIN. . .END;NewSample: PUBLIC PROCEDURE [val: Value] RETURNS [Sample] =NewSampleSet: PUBLIC PROCEDURE RETURNS [nilSet: SampleSet] =RemoveSample: PUBLIC PROCEDURE [toBeRemoved: Sample, from: SampleSet]DescriptionOfChangeChanged by: YourName: DateTimeCHANGE LOGEND.Capitalize the first letter of module,procedure, signal, or type namesCapitalize the first letter of eachimbedded word of a multi-word nameBEGIN sample: Sample;NO names in same scope differingonly by letter case distinctions excepta value with same name as its type butwith lowercase first letterOK to OPEN interface that moduleimplementsKeyword constructors, argument lists,and extractors preferred for multiple-component constructorsCalls on single-argument proceduresUse a small set of ERRORs with anerror code parameter.OK to have locally defined ERRORs Only raise SIGNALs using SIGNAL,ResumableCondition: PUBLIC SIGNAL = CODE;SomeSignal: PUBLIC SIGNAL = CODE;-- SIGNALs: ResumableCondition, SomeSignalattach stylized comments to proce-dures that generate ERRORs orSIGNALs.Only let signals that are part of theabstraction escape out of it.if DIRECTORY entry has a USING listCedar Style SheetAllocateSampleSet : PROCEDURE RETURNS [uninitedSet: SampleSet] =scope where it is heavily usedOK to OPEN an interface in a localOK to use unnamed OPEN of interfacePrint on color printer if you can.-- FILE: CedarSample: DEFINITIONS =IntervalType: Problem: ERROR [reason: ErrorCode];NewSample: PROCEDURE [val: Value] RETURNS [Sample];emptySet: SampleSet = NIL;USING [SomeProc, SomeType],CedarSampleImplBEGIN OPEN CedarSample;x: = 0;IF val = 0 THEN val _ [x];nilSet _ AllocateSampleSet[ ! AllocFault => ERROR Problem[programError] ];nilSet _ [head: NIL, count: 0];BEGIN SomeProc[y];SIGNAL ResumableCondition;AllocFault: ERROR= CODE; -- error for local use in this moduleCedarSampleTYPE = [0 .. upperLimit); -- preferred form for intervalsNaming a type is better than using ananonymous type constructor.don't have to use keyword notationand SIGNALsand ERROR using ERRORNO using ENDCASE to handle a singleremaining case: use as "OTHERWISE"or to generate an ERROR.mesaStandard postlude for a module upperLimit: INTEGER = 32; -- name the upper limit of an interval typeincludes a history log of (non-trivial)changes to the modulePROGRAM module name is normalyformed by suffixing interface namewith "Impl". Alternatively, name maybe totally different than interface'sSomeInterfaceCedarSample;No common suffix on the namesof DEFINITIONS modulesQualify identifiers from interfacesWITH refAnyVar SELECT FROMFiled on [Indigo]Language>StyleSheet.sil, .pressr: REF REAL => r^ _ r^ + 1.0;i: REF INT => { . . .. . . };b: REF BOOLEAN => Standard prelude for a moduleUse REF ANY instead of variantrecords and discriminateSampleSetRec: TYPE = RECORD[head: Sample, count: Value];SampleSet: TYPE = REF SampleSetRec;: PROGRAM IMPORTS SI: SomeInterfaceSI.SomeProcSI.SomeTypeOPEN SI;16 AUG 82xuc3c$9t_JS|>xd$Y3Z!M.xLf!HxuF5E- CBftN=Zrf`&$rA'$PJ3@Zr@&$:WU$=fr2'$r2$=u?4>2t