baskett@decwrl.UUCP (Forest Baskett) (06/27/84)
Subject: DECWRL Modula-2: status report #1 We have mailed out over 30 tapes with more being requested on a steady basis. So far we have received a few compliments and very few complaints so we conclude that the distributed system is being well received so far. Since the original announcement indicated the speed of the compiled code produced by this compiler this, update will try to make clear how well this compiler fits into and supports the UNIX environment with its extensions and standard library modules. Below is the manual page for the system that comes on the tape. In addition to what it describes, there are language extensions that provide convenient control of sizes and alignment of variables so that low level system programming is both feasible and easy. These are described both in the definition files distributed with the system and in a paper that Mike Powell presented at the June '84 USENIX meeting. The next release of the compiler will include extensions for dynamic arrays. I am submitting a note to net.lang describing our current thinking about the details of those extensions. Kudos to Mike Powell, flames to me. Comments welcome. -Forest Baskett MOD(l) UNIX Programmer's Manual MOD(l) NAME mod - Modula-2 compiler SYNOPSIS mod [ option ] name ... DESCRIPTION Mod is a Modula-2 compiler. It compiles one or more Modula-2 program or implementation modules. Definition modules are not compiled. In the absence of options, it will compile all specified modules and link them together into an executable file called a.out. Each program or implementation module must be in a separate file with a name ending with ".mod". Each definition module must be in a separate file called "module.def", where "module" is the name of the module. Object files ending with ".o" compiled with mod or some other compiler may be specified. File name arguments ending with ".pcd" and ".s" are assumed to be pcode and assembly language files, respectively, and are translated and assembled into object files. The following options are available: -c Create object files but do not link them together. -g Generate additional symbol table information for the debugger dbx(1). -i Ignore the fact that there are errors in some of the modules and continue compiling the rest of them. -mflags Perform intermodule checking. If an out-of-date module is encountered, recompile it using the speci- fied "flags". The flags are separated by commas or spaces, and must be quoted if spaces are used. -n Write out what will happen when the same command is entered without the "-n" option. -o name Create an executable file called "name" instead of the default "a.out". -pg Set up object files for profiling by gprof(1). -r Retain pcode and assembly language files in the current directory after compilation. Printed 6/26/84 1 February 1984 1 MOD(l) UNIX Programmer's Manual MOD(l) -s Use standard conventions for reserved word case, car- dinal data type, and strings (See Extensions, below). -sc Use standard conventions for cardinal data type (See Extensions, below). -sk Use standard conventions for reserved word case (See Extensions, below). -ss Use standard conventions for string constants (See Extensions, below). -u Convert all identifiers and reserved words to upper case (i.e., ignore the case of identifiers and reserved words on input). -v Print out messages saying what is happening during compilation. -C Generate runtime checks for illegal pointers, subrange and index bounds, and variant record tags. -Ddirectory Use the specified directory for the phases of the com- piler and the location of the standard definition modules and libraries. -L While performing intermodule checking, ignore refer- ences to modules not specified. (This is useful when checking modules to be placed in a library). -M Perform intermodule checking, but do not recompile if inconsistencies are found. -Nname While performing intermodule checking, ignore refer- ences to the module "name". (This is useful when the module "name" is not a Modula-2 module.) -O Perform code optimizations. -P Stop after generating pcode in a file ending with ".pcd". -S Stop after generating assembly language in a file end- ing with ".s". LIBRARY MODULES By default, an import of a global module will cause the com- piler to look for the definition module first in the working directory and then in the standard library directory. The standard library modules are automatically linked with the Printed 6/26/84 1 February 1984 2 MOD(l) UNIX Programmer's Manual MOD(l) program. The default may be overridden to specify other directories of definition modules using the MODPATH environment vari- able. MODPATH is set to a sequence of directory names separated by colons. Those directories will be searched in the order specified to find any definition module. The corresponding object files or libraries are specified when linking. The MODPATH environment variable may be set by the user in .login or in .modpath in the working directory. If the file ".modpath" exists in the working directory, the mod command will use its first line as the value of the MODPATH variable. The following modules are provided by this implementation of Modula-2: Storage Standard storage module, for compatibility with stan- dard Modula-2. io Pseudo-definition file to document the built-in io module. The io module provides formatted read and write similar to scanf(3) and printf(3). math Mathematical functions. parameters Accesses command line parameters and environment vari- ables. strings Compares, assigns, and concatenates strings. unix Defines some Unix system calls and C library routines. DIFFERENCES AND EXTENSIONS This implementation of Modula-2 has compiled and run Wirth's Modula-2 compiler (as modified by Cambridge University for the VAX) with only minor changes to make that compiler more portable. However, the definition of the language has been relaxed in some areas. For the most part, these changes are upward compatible. The following is an incomplete list of differences between this compiler and Wirth's compiler: Reserved words and standard identifiers are recognized in any case, not just in upper case. Thus, case variations of Printed 6/26/84 1 February 1984 3 MOD(l) UNIX Programmer's Manual MOD(l) reserved words may not be used for identifiers. This feature is disabled by the -sk option. Cardinal and non-negative subranges that do not exceed MAX- INT are considered to be subranges of integer and are compa- tible with integers. Subranges that exceed MAXINT are com- patible with cardinal and non-negative subranges. This feature is disabled by the -sc option. A builtin module called io provides formatted input and out- put. The Readf and Writef routines can accept any number of parameters, so long as their types correspond properly with the format string. Supported formats include: for integer and cardinal, d, x, and o; for real, g (output only), f, and e; for longreal, G (output only), F, and E; for char, c; and for string (array of char), s. No import of allocate or deallocate is required to use new and dispose if the standard memory allocation routines are desired. The sizes returned by size and tsize and expected by allo- cate and deallocate are in units of bits. The system module includes the type byte, which is analogous to word, as well as the constant bytesperword. There is a standard type called longreal that stores a dou- ble precision real value. A standard function longfloat converts cardinals, integers, or reals to longreal. Additional standard procedures include min(a,b) Returns the smaller of two cardinal, integer, real, or longreal values. max(a,b) Returns the larger of two cardinal, integer, real, or longreal values. assert(condition[,message]) Aborts the program (with the optional message) if the condition is false. number(a) Returns the number of elements in the specified array. first(type) Returns the smallest legal value of the specified type. last(type) Printed 6/26/84 1 February 1984 4 MOD(l) UNIX Programmer's Manual MOD(l) Returns the largest legal value of the specified type. Definition modules are not compiled. Escape sequences may be placed in strings to sepecify non- printing characters. E.g., \n, \t, \0, \r, \f, \b, \\, \', and \" mean linefeed, tab, null, carriage return, form feed, backspace, backslash, single quote, and double quote, respectively. A single (double) quote also may be put in a string delimited with single (double) quotes by specifying two single (double) quotes. This feature is disabled by the -ss option. The interface to Unix is through a module called unix rather than the system module. The unixcall procedure is handled for compatibility with the Cambridge compiler, but is not recommended. FILES file.mod Program or implementation module file.def Definition module file.pcd Pcode (-P or -r) file.s Assembly code (-S or -r) /usr/local/lib/mod/mod2.0 Modula-2 compiler front-end /usr/local/lib/mod/mod2.1 Modula-2 compiler back-end /usr/local/lib/mod/mod2.2 Intermodule checker /usr/local/lib/mod/*.def Standard definition modules /usr/local/lib/mod/modlib Default library SEE ALSO N. Wirth, Programming in Modula-2, Springer-Verlag, New York, 1982. DIAGNOSTICS All error messages suppress subsequent compilation phases. Error messages ending with a question mark are internal errors, and probably represent compiler bugs. When pointer checking is enabled in a running Modula-2 program, segmenta- tion faults may be generated by the pointer validation test. These are intentional and should be considered as invalid pointer messages. The compiler runs with runtime checks enabled, and may produce core dumps. Report problems to the author. AUTHOR Michael L. Powell Digital Equipment Corporation Western Research Laboratory 4410 El Camino Real Los Altos, CA 94022 Mail: powell@decwrl or {decvax,ucbvax}!decwrl!powell Printed 6/26/84 1 February 1984 5 MOD(l) UNIX Programmer's Manual MOD(l) Software and documentation is Copyright 1984, Digital Equip- ment Corporation, Maynard, Massachusetts. All rights reserved. This software is provided under license agreement and must be kept confidential. LIMITATIONS This is an experimental compiler, and thus no warranties are expressed or implied about its conformance to the definition of the Modula-2 language or about its proper functioning. We will endeavor to report and fix bugs, but users should be aware that this compiler is not a supported product. Printed 6/26/84 1 February 1984 6