🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.lang.modula2
2 messages
2 total messages Started by David Hiebeler Mon, 17 Aug 1987 17:09
Re: exporting imports
#3740
Author: David Hiebeler
Date: Mon, 17 Aug 1987 17:09
41 lines
2322 bytes
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!"
Re: exporting imports
#3764
Author: Ted Peters
Date: Wed, 19 Aug 1987 16:18
11 lines
1069 bytes
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. 
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads