🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.modula2
Article #117

Re: Re^2: Dynamic arrays in Modula-2?

#117
From: Chuck Lins
Date: Fri, 17 Apr 1992 02:03
28 lines
1235 bytes
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.


-- 
Chuck Lins, Apple Computer, Inc. Oberon-2 Paladin  lins@apple.com
Searching... Searching... Searching for Solevig Dommartin
Technical Details
Message-ID: <65564@apple.Apple.COM>
Path: arc1-ca.pugleaf.net!sparky!uunet!spool.mu.edu!agate!apple!apple!lins
References: <24E38CF4AZ@tron.gun.de>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!spool.mu.edu!agate!apple!apple!lins
From: lins@Apple.COM (Chuck Lins )
Newsgroups: comp.lang.modula2
Subject: Re: Re^2: Dynamic arrays in Modula-2?
Summary: How it's done in Oberon
Message-ID: <65564@apple.Apple.COM>
Date: 17 Apr 92 02:03:26 GMT
Article-I.D.: apple.65564
References: <24E38CF4AZ@tron.gun.de>
Organization: Apple Computer Inc., Cupertino, CA
Lines: 28