🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.modula2
Article #91

Re: Dynamic arrays in Modula-2?

#91
From: Changhao Boh
Date: Fri, 10 Apr 1992 04:06
42 lines
1458 bytes
DM> How does one express dynamic allocation of single and
DM> multi-dimensional arrays in Modula-2?  How does one pass a dynamically
DM> allocated multi-dimensional array as an argument to a procedure?
DM>
DM> For example, if a two or three dimensional array of INTEGERs resides i
DM> file on disk, and the dimensions of the data set are specified at the
DM> beginning of the file, how can the file be loaded and manipulated
DM> using a Modula-2 program?
DM>
DM> My references on Modula-2 lead me to believe that this elementary
DM> operation is difficult or impossible to solve elegantly or portably in
DM> Modula-2.

Via user defined datatypes, sir, user defined datatypes, user defined
datatypes.

You'll have to write your own opaque data sturctures to accomplish what you
want.

To begin,

TYPE
  MultiDimArray   = ARRAY [1..100] [1..100] [A..Z] OF CARDINALS;

  aMultiDimArray  = POINTER TO MultiDimArray;

VAR
  Array : aMultiDimArray;

BEGIN
  ALLOCATE(Array, SIZE(Array^));

  (* Do your stuffs... *)

  DEALLOCATE(Array, SIZE(Array^));

END.


Good Health.

Changhao.
Technical Details
Message-ID: <11353@mindlink.bc.ca>
Path: arc1-ca.pugleaf.net!sparky!uunet!think.com!ames!agate!rsoft!mindlink!a2660

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!think.com!ames!agate!rsoft!mindlink!a2660
From: Changhao_Boh@mindlink.bc.ca (Changhao Boh)
Newsgroups: comp.lang.modula2
Subject: Re: Dynamic arrays in Modula-2?
Message-ID: <11353@mindlink.bc.ca>
Date: 10 Apr 92 04:06:30 GMT
Organization: MIND LINK! - British Columbia, Canada
Distribution: world
Lines: 42