Article View: comp.lang.modula2
Article #118Re: Dynamic arrays in Modula-2?
From: David M. Brumley
Date: Fri, 17 Apr 1992 14:27
Date: Fri, 17 Apr 1992 14:27
36 lines
1851 bytes
1851 bytes
lins@Apple.COM (Chuck Lins ) writes: >Since Guenter Dotzel showed how to do dymanic arrays in ISO Modula-2 I >guess I should demonstrate the way it's done in Oberon(-2). The symbol ><type> shall be a metasyntactic entity representing any type. >MODULE Quux; >TYPE > OpenArray = POINTER TO ARRAY OF <type>; >VAR > myArray : OpenArray; >BEGIN > NEW(myArray, 100); (* for an array of 100 elements *) > (* use the array; e.g. *) > myArray[5] := <variable of <type>>; > (* when done using the variable you will want it garbage collected *) > myArray := NIL; >END Quux. >That's all there is. In Oberon(-2), these array are called "open arrays" >to distinguish them from the dynamic arrays used in paramater passing. THAT's what I was looking for. The previous responses to my question have, I think, confirmed the existence of a flaw in the design of Modula-2. Modula-2's inability to handle "dynamic arrays", by which I mean arrays whose dimensions are not known at compile time, without the support of a nonstandard user defined datatype is extremely frustrating. This flaw discouraged me from using Modula-2 in a graphics project, which I'm now writing in C for lack of a better alternative. I am, however, examining DEC's Modula-3 language which seems to lack the shortcomings of Modula-2 as well as provide lots of new features including objects, threads, and garbage collection.
Technical Details
Message-ID:
<dmb.703520850@srl03.cacs.usl.edu>Path:
arc1-ca.pugleaf.net!sparky!uunet!wupost!tulane!rouge!dmbReferences:
<24E38CF4AZ@tron.gun.de> <65564@apple.Apple.COM>Show Full Headers
Complete Article Headers
Newsgroups: comp.lang.modula2 Path: arc1-ca.pugleaf.net!sparky!uunet!wupost!tulane!rouge!dmb From: dmb@usl.edu (David M. Brumley) Subject: Re: Dynamic arrays in Modula-2? Message-ID: <dmb.703520850@srl03.cacs.usl.edu> Sender: anon@usl.edu (Anonymous NNTP Posting) Organization: Univ. of Southwestern Louisiana References: <24E38CF4AZ@tron.gun.de> <65564@apple.Apple.COM> Date: Fri, 17 Apr 1992 14:27:30 GMT Lines: 36