Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: version B 2.10.2 9/18/84 SMI; site sun.uucp
Path: utzoo!watmath!clyde!cbosgd!ihnp4!qantel!hplabs!pesnta!greipa!decwrl!sun!rmarti
From: rmarti@sun.uucp (Bob Marti)
Newsgroups: net.lang
Subject: Re: C++ and Modula-2 (and something about data abstraction)
Message-ID: <2965@sun.uucp>
Date: Fri, 8-Nov-85 16:50:01 EST
Article-I.D.: sun.2965
Posted: Fri Nov  8 16:50:01 1985
Date-Received: Mon, 11-Nov-85 06:33:15 EST
Distribution: net
Organization: Sun Microsystems, Inc.
Lines: 35

>>     The fact that, in the
>>     current implementations of Modula-2, variables of an opaque type are
>>     typically restricted to a size of 1 or 2 words which forces you to use
>>     a POINTER TO RECORD ... representation is just that:  An implementation
>>     restriction.

>    Much as I like Modula-2, I can't agree with this statement.  The reason
> such a type is restricted is because, given the current syntax and semantics
> of the language, the compiler has no way to obtain size information about
> an opaque object.  Such objects are named in the definition module, but
> declared in the implementation module.  A program importing them may only
> read the definition module (of course), where no information is available.

This is true if you assume that the compiler allocates storage (and assigns
addresses) for variables of an imported opaque type when compiling an
implementation module.  I guess that this is the way all current Modula-2
(and other) compilers work.  (I only know the Lilith M2M 4-pass compiler
reasonably well.)

Although I have not worked out the idea in all details, I believe that the
size information has to be available at link-time, but not necessarily at
compile-time.  In other words, the compiler could leave hooks in the code
instructing the linker to allocate variables of the appropriate size and
assign addresses to them.  Of course, this requires writing a special
linker which handles this case.  It also means that linking will be more
expensive.  Since most Modula-2 implementations have a special linker
which checks for compatible versions of the modules to be linked, such
a scheme would not really make matters worse.  And since Niklaus Wirth's
new 1-pass Modula-2 compiler compiles itself in less than 2 minutes on
the Lilith (a Lilith has about the computing power of a VAX-11/750),
I would expect that even with this "expensive" linking scheme the total
time to compile and link still compares favorably to most compilers out
on the market (especially to all Ada compilers :-).

PS: As far as I know, the new 1-pass compiler is not publicly available (yet).