Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site decwrl.UUCP Path: utzoo!dciem!nrcaero!pesnta!amd!dual!decwrl!joel From: joel@decwrl.UUCP (Joel McCormack) Newsgroups: net.lang,net.lang.mod2 Subject: Re: Modula-2 an insuggicient language Message-ID: <398@decwrl.UUCP> Date: Wed, 30-Jan-85 18:58:34 EST Article-I.D.: decwrl.398 Posted: Wed Jan 30 18:58:34 1985 Date-Received: Fri, 1-Feb-85 21:24:10 EST Organization: DEC Western Software Lab, Los Altos, CA Lines: 47 Modula-2 IS a good language for hacking, in fact, it was the combination of type-checking and low-level access that first got me interested in the language. David Sher's "problem" with dynamic arrarys is actually pretty easy. TYPE DynamicArray = POINTER TO ARRAY [0..0] (* [0..MaxInt] is also good *) OF CARDINAL (* or whatever *); Image = RECORD numberColumns: CARDINAL; numberRows : CARDINAL; image : DynamicArray; END; ... assume you have just filled in numberColumns and numberRows... WITH Image DO ALLOCATE (image, numberColumns*numberRows*TSIZE(CARDINAL)); END; ...accessing row, column, assuming 0-based... (* turn off range-checking if used [0..0] *) WITH Image DO image^[row*numberColumns + column] := ... END; Now, is that really significantly different from C? I would prefer to have support for dynamic arrays directly in the language, so that you wouldn't have to do your own array subscript calculations, and you could get range-checking as part of the normal indexing operation. But Modula-2 is certainly USABLE for this kind of thing. A real-life example is a Modula-2 program called StatPak by Richard Sincovec and Richard Wiener. This programs implements virtual arrays that can exist on disk, or in memory, and made use of the technique above. They also claimed that since they had modules to help get the organization of the program down, and type-checking to keep them from spending the rest of their lives debugging, they were able to include substantially more goodies running at a higher speed than the other statistical packages for micros. -- - Joel McCormack {ihnp4 decvax ucbvax allegra sequent utcsrgv}!decwrl!joel joel@decwrl.arpa