From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,5556ca7de188d5ef,start X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-12-11 14:22:36 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!news-FFM2.ecrc.net!news.iks-jena.de!lutz From: lutz@iks-jena.de (Lutz Donnerhacke) Newsgroups: comp.lang.ada Subject: Multidimensional array vs. array of array Date: Tue, 11 Dec 2001 22:22:00 +0000 (UTC) Organization: IKS GmbH Jena Message-ID: NNTP-Posting-Host: belenus.iks-jena.de X-Trace: branwen.iks-jena.de 1008109320 28877 217.17.192.34 (11 Dec 2001 22:22:00 GMT) X-Complaints-To: usenet@iks-jena.de NNTP-Posting-Date: Tue, 11 Dec 2001 22:22:00 +0000 (UTC) User-Agent: slrn/0.9.6.3 (Linux) Xref: archiver1.google.com comp.lang.ada:17787 Date: 2001-12-11T22:22:00+00:00 List-Id: How does a skilled Ada programmer define a return type containing a multidimensional array? Of course, the simple solution works: type Equations is array (Rows range <>, Columns range <>) of Number; type Workspace (row : Rows; col : Columns) is record eqs : Equations (Rows'First .. row, Columns'First .. col); ... some more stuff ... end record; function Init_Workspace return Workspace; But this approach fails miserably on extracting a single row from the result as well as on construction the result in a recursive function. I do not found a way to define this type as an array of arrays despite writing a generic package over the maximum values: generic type Columns is range <>; package type Equation is arry (Columns) of Number; type Equations is array (Rows range <>) of Equation; type Workspace (row : Rows) is record eqs : Equations (Rows'First .. row); ... some more stuff ... end record; function Init_Workspace return Workspace; end package; But this approach does not work for a situation where determining the resulting constraints is equivalent to simulating the Init_Workspace recursion. This should be avoided: Error-prone, duplicated and slightly modified code. Any idea?