CS 342 Lecture -*- Outline -*- * Type checking ** structural (for equates) ai1 = array[int] ai2 = array[int] x: ai1 := ai2$[0: 4] ** By name for abstract types names of clusters distinct name of cluster is NOT equal to rep type of cluster true even inside the cluster so name equiv. for clusters ** No Coercions all have to be explicit, e.g. real$r2i(3.4) % rounds to 3 ** Across module boundaries (library) uses library to check separately compiled units library information is kept in a file *** module interfaces **** modules: procedures, clusters, (and iterators) but not operations of a cluster. no nesting **** interface (signature) information needed to use a module (only) number and types of arguments number and types of results names of exceptions (and number/type of exception results) names of exported operations (for clusters) (names of type parameters, for parameterized modules) **** DU (description unit) name (identity) of an interface in library used by linker to resolve external references place DU in binary object file for a module along with DUs of referenced modules linker must find those other DUs in other binary object files. **** compilation environment map from names to DUs e.g. label = int allows different modules to be compiled according to different naming conventions helps in merging programs written at different places *** practical steps in using the CLU compiler and library **** spec files interfaces, comments with specs, but no implementations named (by convention) *.spc **** compilation environment files contain global equates (synonyms) (makes future modifications easier) **** creating a library to create library in file lib.lib run: clu #ce ce.equ #spec *.spc #dump lib.lib only have to do this when *.spc or *.equ files change **** compiling a file to compile the file instr.clu (an implementation) run: clu #ce ce.equ #merge lib.lib #compile instr.clu should check against library, but will not warn if interface of instr.clu differs from instr.spc