hiebeler@csv.rpi.edu (David Hiebeler) (08/17/87)
References: Keywords: About exporting types, vars, and procs that were imported: I was told that this does not work on some (even most?) compilers. I am using a DEC Compiler (Which, remember, is NOT a supported product of DEC), on the VAX 11/780. Here is exactly the form I use: in the DEFINITION MODULE FROM io IMPORT (* type *) File, (* var *) Input,Output, (* proc *) Open, Close; EXPORT QUALIFIED (* from io *) File, Input, Output, Open, Close, (* my own *) Write, WriteReal, WriteLn, .... ; I do not re-declare what the things are, or do things like: PROCEDURE Open(Fname:ARRAY OF CHAR; Mode:CHAR):File; I do declare my own procedures: PROCEDURE Write(Fname:File; Str:ARRAY OF CHAR); Within the IMPLEMENTATION MODULE, I have this statement: FROM io IMPORT Open, Close, File, Readf, Writef; Note that Input and Output need not be imported, as they will be passed as parameters to the I/O procedures if they are needed. Readf and Writef are the procedures from io, which my own procedures call. I guess it's just a matter of luck whether you can do these things with your compiler. I am certainly glad that the one I use can; these things are very natural to do, and certainly make things easier! I suppose an alternative would be simply to import the sub-module items (Input,Output, File,Open,Close) in any program modules which needs them: FROM io IMPORT Open, Close, Input, Output, File; FROM InOut IMPORT Write, WriteLn, ReadReal, ...; and in the DEFINITION MODULE of InOut, simply don't export the things from io. -D.H. ---- David Hiebeler hiebeler@csv.rpi.edu Chatham, NY "Illusions, Richard! Every (also Troy, NY) bit of it illusions!"
peters@metheus.UUCP (Ted Peters) (08/19/87)
You should certainly be able to export imports directly. For instance if you wanted to make a new InOut module, with some of the procedures being different, you shouldn't have to rewrite all of them (even if you're only calling the old ones). Forcing the module that uses NewInOut to also export some routines from InOut would be inconvenient, and it would not sufficiently abstract the lower level module. I hope all compilers support this... - Ted Peters Disclaimer : All Mine.