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=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,9eef6c480abeecf8 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news3.google.com!news.glorb.com!logbridge.uoregon.edu!newsfeed.cs.utexas.edu!geraldo.cc.utexas.edu!not-for-mail From: bdbryant@mail.utexas.edu (Bobby D. Bryant) Newsgroups: comp.lang.ada Subject: Re: Dynamic array allocation and STL equivalents? Date: Sat, 12 Feb 2005 06:19:30 +0000 (UTC) Organization: dis- Message-ID: References: <1108127216.221977.60830@o13g2000cwo.googlegroups.com> Reply-To: bdbryant@mail.utexas.edu NNTP-Posting-Host: dial-b-128-83-204-121.telesys.its.utexas.edu Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: geraldo.cc.utexas.edu 1108189170 8424 128.83.204.121 (12 Feb 2005 06:19:30 GMT) X-Complaints-To: abuse@utexas.edu NNTP-Posting-Date: Sat, 12 Feb 2005 06:19:30 +0000 (UTC) X-Newsreader: knews 1.0b.1 Xref: g2news1.google.com comp.lang.ada:8270 Date: 2005-02-12T06:19:30+00:00 List-Id: On Fri, 11 Feb 2005, brian.b.mcguinness@lmco.com wrote: > One interesting project would be to create an object class hierarchy to > implement APL arrays. In APL, the lengths of an array's dimensions can > change, e.g. by concatenating new rows or columns onto a matrix, or > concatenating two matrices, and the number of dimensions can also > change, e.g. by "laminating" two 12x30 arrays to form a 2x12x30 array. > In C++, an obvious solution would be to use STL vectors, e.g.: > > class RealArray { > private: > vector dimensions; > vector data; > public: > // define an indexing operator[] to use the dimensions > // vector to translate sets of indices into offsets > // into the data array > ... > }; > > But I don't know how to do this in Ada. If you can work out the recursive data typing issues, you might be able to do it by overloading the '&' catenation operator to bind a new row/column/layer onto an array or matrix. The indexing would be tricky, but if you want think of an array access as a sort of function call (send an argument, get a result), you might be able to kludge together a function to do the work. Let the function's first argument be the data structure, and the second a pointer to an (unconstrained) array type that holds the (variable length) value of the indices of interest. I think the concept is sound, if you can get everything past the type checking, though specifying the indices in a program might be tedious. -- Bobby Bryant Austin, Texas