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.2 required=5.0 tests=BAYES_00,INVALID_MSGID, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,5a9bede4d09438a9 X-Google-Attributes: gid103376,public From: Pawel Kobylarz Subject: Re: Unbounded array Date: 1999/04/27 Message-ID: <37260F1E.17592342@wbkst21.mach.uni-karlsruhe.de>#1/1 X-Deja-AN: 471582581 Content-Transfer-Encoding: 7bit References: <37247AA2.116F5E00@wbkst21.mach.uni-karlsruhe.de> <7g23a9$k3k$1@nnrp1.dejanews.com> Content-Type: text/plain; charset=us-ascii X-Complaints-To: usenet@rz.uni-karlsruhe.de X-Trace: news.rz.uni-karlsruhe.de 925241119 5566 129.13.175.21 Organization: University of Karlsruhe Mime-Version: 1.0 Reply-To: kobylarz@wbkst21.mach.uni-karlsruhe.de Newsgroups: comp.lang.ada Date: 1999-04-27T00:00:00+00:00 List-Id: Robert Dewar wrote: > In article > <37247AA2.116F5E00@wbkst21.mach.uni-karlsruhe.de>, > kobylarz@wbkst21.mach.uni-karlsruhe.de wrote: > > Is there in ADA a way to obtain something like unbouned > > array? > > Well most certainly you can use EXACTLY the same procedure > you use in C (lookup allocators and the NEW keyword in your > Ada text book). > > But if you are using GNAT, also look up GNAT.Table (in file > g-table.ads) which provides exactly the abstraction you are > looking for. > > -----------== Posted via Deja News, The Discussion Network ==---------- > http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own The GNAT.table does not seem to work correctly, and there is also something strange in the definition. Let's suppose I want to enlarge the table. Here are two definitions from the g-table.ads file: procedure Set_Last (New_Val : Table_Index_Type); pragma Inline (Set_Last); -- This procedure sets Last to the indicated value. If necessary the -- table is reallocated to accomodate the new value (i.e. on return -- the allocated table has an upper bound of at least Last). If Set_Last -- reduces the size of the table, then logically entries are removed -- from the table. If Set_Last increases the size of the table, then -- new entries are logically added to the table. procedure Increment_Last; pragma Inline (Increment_Last); -- Adds 1 to Last (same as Set_Last (Last + 1). The strange thing is that the functions does not take object as a parameter. They cannot be called like table'Increment_Last; or table.Increment_Last; or Increment_Last(table); there are compilation erros. However, line like: Increment_Last; does compile! The question is: if I have two object of that class and want to resize one of them, how should I call it? I was also curious what is the effect of the function. I wrote type My_Type is record ... end record; subtype My_Idx_Type is Integer; package t_mytype is new Gnat.Table(My_Type, My_Idx_Type, 1, 1, 10); table : t_mytype.Table_Ptr; begin loop Put_Line("before..."); Increment_Last; Put_Line("after!"); end loop end; and I obtained before... after! before... and the program hanged in this place. Seemingly the function does not work and I cannot even imagine, how can it work without taking object as a parameter. Any suggestions? Pawel Kobylarz