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-Thread: 103376,be7fa91648ac3f12 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news3.google.com!news.glorb.com!hermod.ttsg.com!news-out.ntli.net!newsrout1-gui.ntli.net!ntli.net!newspeer1-win.ntli.net!newsfe1-win.ntli.net.POSTED!53ab2750!not-for-mail From: "Dr. Adrian Wrigley" Subject: Re: Large arrays (again), problem case for GNAT User-Agent: Pan/0.14.2 (This is not a psychotic episode. It's a cleansing moment of clarity.) Message-Id: Newsgroups: comp.lang.ada References: MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit Date: Fri, 15 Apr 2005 14:31:30 GMT NNTP-Posting-Host: 81.100.88.147 X-Complaints-To: http://www.ntlworld.com/netreport X-Trace: newsfe1-win.ntli.net 1113575490 81.100.88.147 (Fri, 15 Apr 2005 15:31:30 BST) NNTP-Posting-Date: Fri, 15 Apr 2005 15:31:30 BST Organization: ntl Cablemodem News Service Xref: g2news1.google.com comp.lang.ada:10499 Date: 2005-04-15T14:31:30+00:00 List-Id: On Fri, 15 Apr 2005 15:21:32 +0200, Dmitry A. Kazakov wrote: > On Fri, 15 Apr 2005 11:49:23 GMT, Dr. Adrian Wrigley wrote: > ... >> I couldn't understand why there was no decent mechanism for changing >> the size of an array. The resulting code was much cleaner, faster >> and more memory efficient than using fancy data structures/container >> libraries. >> >> Why did the language not provide an equivalent of 'realloc' for >> arrays? > > I would propose: > > generic > type Element_Type is limited private; > type Index_Type is (<>); > type Array_Type is array (Index_Type) of Element_Type; > type Access_Type is access Array_Type; > procedure Ada.Array_Resize (X : in out Access_Type; Elements : Integer); > > and > > generic > type Element_Type is private; > type Index_Type is (<>); > type Array_Type is array (Index_Type) of Element_Type; > type Access_Type is access Array_Type; > procedure Ada.Array_Expand > ( X : in out Access_Type; > Elements : Natural; > Initial : Element_Type > ); This looks plausible. Could we specify the new 'Last index instead of the Elements parameter? (what about a new 'First index?) Maybe you'd have difficulty creating a zero element array though. It'd be nice if it was less verbose too. 'new' seems so simple to use - something equally simple would be nice for resizing. Maybe an extra parameter for new or something(?) -- Adrian