Article View: comp.lang.modula2
Article #4576Re: Re: C++ vs. Modula2
From: Gernot Heiser
Date: Thu, 19 Jan 1989 19:31
Date: Thu, 19 Jan 1989 19:31
75 lines
3934 bytes
3934 bytes
In article <INFO-M2%89011219330825@UCF1VM> Info-Modula2 Distribution List <INFO-M2%UCF1VM.bitnet@jade.berkeley.edu> writes:
>
>quoth Gernot Heiser <mcvax!cernvax!ethz!iis!heiser@UUNET.UU.NET>:
[ ... ]
>As was recently observed in the info-pascal mailing list, optimization ->
>conditional compilation. Consider:
[ example deleted]
>All but the most inanely STUPID of compilers will completely eliminate the
>unreachable code.
This has already been clarified by other posters.
>>Both have serious deficiencies here. The most serious one is probably the
>>impossibility to pass multi dimensional arrays of vaying size to subprograms.
>>Linearizing your matrices to be able to pass them to subprograms is a step back
>>towards assembler code.
[ ... ]
>I don't understand how it is 'impossible' to pass such arrays in C. I may
>not be cognizant of changes made by the ANSI standard in this regard, but
>each dimensional component of a C array being merely a pointer, one may
>readily pass any array of any structural characteristic, to a 'subprogram'.
>It is however, necessary to pass explicit information regarding the run-time
>structural characteristics of such a data object, in order to prevent
>inappropriate memory accesses.
Of course you can pass multi dimensional arrays to C procedures, but there are
no multi-dimensional open array parameters. Consider
SUBROUTINE sub (N,A)
INTEGER N
REAL A(N,*)
i.e. a formal array where the size of more than one dimension is variable. Both
Modula-2 and C only allow one dimension to be "open". (If anybody knows of an
elegant means (NOT a hack) to do this in C++ I'd be interested to hear about
it.
>Nor do I understand what is unreal about
>C's 'for'. It is a powerful generalization (within it's limited domain)
>of the BASIC/Pascal/Modula, etc. 'for'. I'd like to know what objections
>you have to the character of the C 'for', please.
Some call it powerful, others call it messy. First of all it is not a
generalization of BASIC/Pascal/Modula, its a leftover of one of ALGOL/60's
worst features. C's 'for' is really a 'while' with an initialization clause and
a designated spot that may contain an incrementation clause. What I consider a
"real" 'for' (as opposed to the while/repeat/loop family) is a construct that
executes a specific number ot times, the iteration count being determined
BEFORE the processing of the body starts. This is what is really needed most of
the time in numerical programs. The other cases are exactly what while/repeat/
loop constructs are for.
>>....Modula provides no means to switch between single
>>and double precision depending on the hardware (e.g. using single precision on
>>>= 48 bit hardware, double precision otherwise). C makes that easy using
>>#define.
>
>Again, conditional compilation...
If you ever see anything like
IF this_is_a_CRAY THEN
VAR number: REAL;
ELSE
VAR number: LONG REAL;
END;
then it's certainly not Modula-2 (nor a language I could imagine to be
particularly fond of).
>I hope that my comments will be construed constructively and prove sufficiently
>non-trivial to provoke some rejoinder.
you asked for it :-)
--
Gernot Heiser Phone: +41 1/256 23 48
Integrated Systems Laboratory CSNET/ARPA: heiser%iis.ethz.ch@relay.cs.net
ETH Zuerich UUCP (new): heiser@iis.uucp
CH-8092 Zuerich, Switzerland UUCP (old): {uunet,mcvax,...}!iis!heiser
Technical Details
Message-ID:
<739@jupiter.iis.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!attcan!uunet!mcvax!cernvax!ethz!iis!heiserReferences:
<INFO-M2%89011219330825@UCF1VM>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!mcvax!cernvax!ethz!iis!heiser From: heiser@iis.UUCP (Gernot Heiser) Newsgroups: comp.lang.modula2 Subject: Re: Re: C++ vs. Modula2 Message-ID: <739@jupiter.iis.UUCP> Date: 19 Jan 89 19:31:52 GMT References: <INFO-M2%89011219330825@UCF1VM> Reply-To: heiser@iis.ethz.ch (Gernot Heiser) Organization: Integrated Systems Lab., ETH Zuerich Lines: 75 Summary: Expires: