Modula-2 Reloaded

A Modern Typesafe & Literate Programming Notation

Site Menu

Project

Specification

Implementation

Recommendations

Reference

Needs Updating

Work in Progress

Wastebasket

Wiki Manual

edit SideBar

Pervasive IO As An Import Aggregator

WiP.PervasiveIOAsAnImportAggregator History

Hide minor edits - Show changes to output

2010-01-19 16:34 by benjk -
Changed line 23 from:
IMPORT BITSET*, BOOLEAN*, OCTET*, CHAR*, UNICHAR*, CARDINAL*, LONGCARD*, INTEGER*, LONGINT*, REAL*, LONGREAL*;
to:
IMPORT BITSET+, BOOLEAN+, OCTET+, CHAR+, UNICHAR+, CARDINAL+, LONGCARD+, INTEGER+, LONGINT+, REAL+, LONGREAL+;
2010-01-19 16:33 by benjk -
Changed line 9 from:
IMPORT BITSET*, BOOLEAN*, OCTET*, CHAR*, UNICHAR*, CARDINAL*, LONGCARD*, INTEGER*, LONGINT*, REAL*, LONGREAL*;
to:
IMPORT BITSET+, BOOLEAN+, OCTET+, CHAR+, UNICHAR+, CARDINAL+, LONGCARD+, INTEGER+, LONGINT+, REAL+, LONGREAL+;
2010-01-17 07:30 by benjk -
Deleted lines 5-6:

FROM FileIO IMPORT File;
2010-01-17 07:29 by benjk -
Changed line 1 from:
When using a library model with one I/O module for each pervasive type, each I/O module must be imported separately before use. In most situations this would be rather inconvenient. It is therefore desirable to be able to import all pervasive I/O modules with a single import directive. The following is an example how module `PervasiveIO could be provided as an aggregator module for all pervasive I/O procedures. The example assumes that module identifiers following @@IMPORT@@ marked with an asterisk are re-exported by the module.
to:
When using a library model with one I/O module for each pervasive type, each I/O module must be imported separately before use. In most situations this would be rather inconvenient. It is therefore desirable to be able to import all pervasive I/O modules with a single import directive. The following is an example how module `PervasiveIO could be provided as an aggregator module for all pervasive I/O procedures. The example assumes an extension of the import statement syntax whereby module identifiers following @@IMPORT@@ marked with an asterisk are re-exported by the module.
2010-01-17 07:27 by benjk -
Changed lines 1-2 from:
When using a library model with one I/O module for each pervasive type, each I/O module must be imported separately before use. In most situations this would be rather inconvenient. It is therefore desirable to be able to import all pervasive I/O modules with a single import directive. The following is an example how module `PervasiveIO can be designed to serve as an aggregator module for all pervasive I/O procedures. For brevity, procedures with formatting parameters are omitted in this example.
to:
When using a library model with one I/O module for each pervasive type, each I/O module must be imported separately before use. In most situations this would be rather inconvenient. It is therefore desirable to be able to import all pervasive I/O modules with a single import directive. The following is an example how module `PervasiveIO could be provided as an aggregator module for all pervasive I/O procedures. The example assumes that module identifiers following @@IMPORT@@ marked with an asterisk are re-exported by the module.
Changed lines 9-11 from:
(* Import type specific pervasive I/O modules for implicit re-export *)

IMPORT BITSET, BOOLEAN, OCTET, CHAR, UNICHAR, CARDINAL, LONGCARD, INTEGER, LONGINT, REAL, LONGREAL;
to:
(* Import type specific pervasive I/O modules for explicit re-export *)

IMPORT BITSET*, BOOLEAN*, OCTET*, CHAR*, UNICHAR*, CARDINAL*, LONGCARD*, INTEGER*, LONGINT*, REAL*, LONGREAL*;

END PervasiveIO.@]

The aggregator module may provide additional facilities of its own. The following example shows how module `PervasiveIO could further provide aliases for all I/O procedures following old-style Modula-2 naming conventions.  For brevity, procedures with formatting parameters are omitted in this example.

[@DEFINITION MODULE PervasiveIO;

(* Aggregator module for all pervasive I/O operations *)

FROM FileIO IMPORT File;

(* Import type specific pervasive I/O modules for explicit re-export *)

IMPORT BITSET*, BOOLEAN*, OCTET*, CHAR*, UNICHAR*, CARDINAL*, LONGCARD*, INTEGER*, LONGINT*, REAL*, LONGREAL*;

(* Provide old-style Modula-2 naming for I/O procedures *)
2010-01-16 17:21 by benjk -
Changed lines 1-2 from:
When using a library model with one I/O module for each pervasive type, each I/O module must be imported separately before use. In most situations this would be very inconvenient. It is therefore desirable to be able to import all pervasive I/O modules with a single import directive. The following is an example how module `PervasiveIO can be designed to serve as an aggregator module for all pervasive I/O procedures. For brevity, procedures with formatting parameters are omitted in this example.
to:
When using a library model with one I/O module for each pervasive type, each I/O module must be imported separately before use. In most situations this would be rather inconvenient. It is therefore desirable to be able to import all pervasive I/O modules with a single import directive. The following is an example how module `PervasiveIO can be designed to serve as an aggregator module for all pervasive I/O procedures. For brevity, procedures with formatting parameters are omitted in this example.
Changed lines 11-17 from:
IMPORT BOOLEAN, OCTET, CHAR, UNICHAR, CARDINAL, LONGCARD, INTEGER, LONGINT, REAL, LONGREAL;
to:
IMPORT BITSET, BOOLEAN, OCTET, CHAR, UNICHAR, CARDINAL, LONGCARD, INTEGER, LONGINT, REAL, LONGREAL;

(* Convenience wrappers for BITSET.Read and BITSET.Write *)

<*INLINE*> PROCEDURE ReadBitset( fid : File; VAR b : BOOLEAN );

<*INLINE*> PROCEDURE WriteBitset( fid : File; b : BOOLEAN )
;
2010-01-14 08:47 by benjk -
Changed lines 11-12 from:
IMPORT BOOLEAN, CHAR, UNICHAR, CARDINAL, LONGCARD, INTEGER, LONGINT, REAL, LONGREAL;
to:
IMPORT BOOLEAN, OCTET, CHAR, UNICHAR, CARDINAL, LONGCARD, INTEGER, LONGINT, REAL, LONGREAL;
Added lines 18-23:

(* Convenience wrappers for OCTET.Read and OCTET.Write *)

<*INLINE*> PROCEDURE ReadOctet( fid : File; VAR b : OCTET );

<*INLINE*> PROCEDURE WriteOctet( fid : File; b : OCTET );
2010-01-14 06:50 by benjk -
Changed line 1 from:
When using a library model with one I/O module for each pervasive type, each I/O module must be imported separately before use. In most situations this would be very inconvenient. It is therefore desirable to be able to import all pervasive I/O modules with a single import directive. The following is an example how module PervasiveIO can be designed to serve as an aggregator module for all pervasive I/O procedures. For brevity, procedures with formatting parameters are omitted in this example.
to:
When using a library model with one I/O module for each pervasive type, each I/O module must be imported separately before use. In most situations this would be very inconvenient. It is therefore desirable to be able to import all pervasive I/O modules with a single import directive. The following is an example how module `PervasiveIO can be designed to serve as an aggregator module for all pervasive I/O procedures. For brevity, procedures with formatting parameters are omitted in this example.
2010-01-14 06:49 by benjk - new file by benjk
Added lines 1-81:
When using a library model with one I/O module for each pervasive type, each I/O module must be imported separately before use. In most situations this would be very inconvenient. It is therefore desirable to be able to import all pervasive I/O modules with a single import directive. The following is an example how module PervasiveIO can be designed to serve as an aggregator module for all pervasive I/O procedures. For brevity, procedures with formatting parameters are omitted in this example.

[@DEFINITION MODULE PervasiveIO;

(* Aggregator module for all pervasive I/O operations *)

FROM FileIO IMPORT File;

(* Import type specific pervasive I/O modules for implicit re-export *)

IMPORT BOOLEAN, CHAR, UNICHAR, CARDINAL, LONGCARD, INTEGER, LONGINT, REAL, LONGREAL;

(* Convenience wrappers for BOOLEAN.Read and BOOLEAN.Write *)

<*INLINE*> PROCEDURE ReadBool( fid : File; VAR b : BOOLEAN );

<*INLINE*> PROCEDURE WriteBool( fid : File; b : BOOLEAN );

(* Convenience wrappers for CHAR.Read and CHAR.Write *)

<*INLINE*> PROCEDURE ReadChar( fid : File; VAR ch : CHAR );

<*INLINE*> PROCEDURE WriteChar( fid : File; ch : CHAR );

(* Convenience wrappers for UNICHAR.Read and UNICHAR.Write *)

<*INLINE*> PROCEDURE ReadUChar( fid : File; VAR ch : UNICHAR ):

<*INLINE*> PROCEDURE WriteUChar( fid : File; ch : UNICHAR );

(* Convenience wrappers for CARDINAL.Read and CARDINAL.Write *)

<*INLINE*> PROCEDURE ReadCard( fid : File; VAR num : CARDINAL );

<*INLINE*> PROCEDURE WriteCard( fid : File; num : CARDINAL );

(* Convenience wrappers for LONGCARD.Read and LONGCARD.Write *)

<*INLINE*> PROCEDURE ReadLCard( fid : File; VAR num : LONGCARD );

<*INLINE*> PROCEDURE WriteLCard( fid : File; num : LONGCARD );

(* Convenience wrappers for INTEGER.Read and INTEGER.Write *)

<*INLINE*> PROCEDURE ReadInt( fid : File; VAR num : INTEGER );

<*INLINE*> PROCEDURE WriteInt( fid : File; num : INTEGER );

(* Convenience wrappers for LONGINT.Read and LONGINT.Write *)

<*INLINE*> PROCEDURE ReadLInt( fid : File; VAR num : LONGINT );

<*INLINE*> PROCEDURE WriteLInt( fid : File; num : LONGINT );

(* Convenience wrappers for REAL.Read and REAL.Write *)

<*INLINE*> PROCEDURE ReadReal( fid : File; VAR num : REAL );

<*INLINE*> PROCEDURE WriteReal( fid : File; num : REAL );

(* Convenience wrappers for LONGREAL.Read and LONGREAL.Write *)

<*INLINE*> PROCEDURE ReadLReal( fid : File; VAR num : LONGREAL );

<*INLINE*> PROCEDURE WriteLReal( fid : File; num : LONGREAL );

END PervasiveIO.@]

All wrapper procedures are implemented as inline procedures as illustrated by the following examples  ...

[@(* Implementation of wrappers for CHAR.Read and CHAR.Write *)

<*INLINE*> PROCEDURE ReadChar( fid : File; VAR ch : CHAR );
BEGIN
    CHAR.Read( fid, ch );
END ReadChar;

<*INLINE*> PROCEDURE WriteChar( fid : File; ch : CHAR );
BEGIN
    CHAR.Write( fid, ch );
END WriteChar;@]