[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Gm2] equality, inequality tests and structured types

From: Andreas Fischlin
Subject: Re: [Gm2] equality, inequality tests and structured types
Date: Sun, 18 Jan 2009 14:03:57 +0100
User-agent: Thunderbird (Macintosh/20081209)

Hi Gaius,

Gaius Mulley wrote:

fortunately in the M2 ISO standard on p263 the section "
Variable Parameter Compatibility" states very nearly the same:

"The formal type of a variable parameter shall be compatible with the
type of an actual variable if any of the following statements is true:

a)  The formal type is the address type and the actual type is any
pointer type.

although interestingly (unless opaque types are covered the statement
(a) - which I doubt) it disallows opaque and ADDRESS parameter
compatibility.  [This can be easily turned on/off via -fiso, -fpim2,
-fpim3 and -fpim4 options]

I'm no sure I quite get what you are saying here. I believe the statement a) is quite appropriate. Indeed, I would expect this compatibility to be given in any good Modula-2 implementation. However, I see no reference there to opaque types. Do yo then mean what would be needed is another statement in the ISO standard, one that would cover also compatibility questions of opaque types in the case of variable proc parameters?

I have a pragmatic view here: I believe it is best to expect from a Modula-2 implementation to use type SYSTEM.ADDRESS for implementing opaque types. Then a coercion of the following kind (emphasized in red) is possible for any opaque type:

In high-level (user visible module) definition module:


In the implementation of the high-level (user visible module):

  PROCEDURE DeclMatrix( VAR m: Matrix;
                        nRows, nCols: INTEGER;
                        name : ARRAY OF CHAR   );
    VAR theMat: MLBase.Matrix;
    theMat := MLBase.Matrix( m );
    MLBase.DeclMatrix( theMat, nRows, nCols, name );
    m := Matrix( theMat );
  END DeclMatrix;
In low-level (internal) definition module:       
    Matrix = POINTER TO MatrixData; (* implementation of Matrices.Matrix *)
    MatrixData = RECORD
  PROCEDURE DeclMatrix( VAR m: Matrix;
                        nRows, nCols: INTEGER;
                        name : ARRAY OF CHAR   );
      Allocate( m, SIZE(MatrixData) );

BTW, we use above technique in RAMES quite lots and I argue such constructs should be possible in any powerful Modula-2 implementation.

ETH Zurich
Prof. Dr. Andreas Fischlin
Systems Ecology - Institute of Integrative Biology
CHN E 21.1
Universitaetstrasse 16
8092 Zurich


+41 44 633-6090 phone
+41 44 633-1136 fax

             Make it as simple as possible, but distrust it!

Attachment: andreas_fischlin.vcf
Description: Vcard

reply via email to

[Prev in Thread] Current Thread [Next in Thread]