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,24d7acf9b853aac8 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news1.google.com!news.glorb.com!news.musoftware.de!wum.musoftware.de!newsfeed.straub-nv.de!noris.net!newsfeed.arcor.de!newsspool3.arcor-online.net!news.arcor.de.POSTED!not-for-mail Date: Fri, 13 Aug 2010 12:30:59 +0200 From: Georg Bauhaus User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.2.8) Gecko/20100802 Thunderbird/3.1.2 MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: S-expression I/O in Ada References: <547afa6b-731e-475f-a7f2-eaefefb25861@k8g2000prh.googlegroups.com> <203526c0-f031-4dfe-b3e0-cd5156de14b8@z28g2000yqh.googlegroups.com> <97ddc8e7-8e18-4d07-aaff-534ead00f4b9@d8g2000yqf.googlegroups.com> In-Reply-To: <97ddc8e7-8e18-4d07-aaff-534ead00f4b9@d8g2000yqf.googlegroups.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Message-ID: <4c651ee3$0$7653$9b4e6d93@newsspool1.arcor-online.net> Organization: Arcor NNTP-Posting-Date: 13 Aug 2010 12:30:59 CEST NNTP-Posting-Host: bef09176.newsspool1.arcor-online.net X-Trace: DXC=ec1\XKEOA:lIkjb;<8iR=aic==]BZ:afn4Fo<]lROoRa<`=YMgDjhgbMBHNc?NkSHnnc\616M64>jLh>_cHTX3jmI^d4;;=mJNi X-Complaints-To: usenet-abuse@arcor.de Xref: g2news1.google.com comp.lang.ada:13212 Date: 2010-08-13T12:30:59+02:00 List-Id: On 13.08.10 10:56, Natacha Kerensikova wrote: > Ada arrays are statically sized, Not quite, but I think you mean that once an array is allocated, you can't add more components than are declared by the index constraint? Example: procedure Uses_Array (N : Positive; ...) is X : array (1 .. N) of Character; -- now fixed to N compoments begin... But Ada's Container packages can provide for the desired flexibility. There are containers of homogeneous components and containers of heterogeneous components. The latter have _Indefinite in their package's names. Example: package Vecs is new Ada.Containers.Indefinite_Vectors (Element_Type => Types.Heterogenous'Class, Index_Type => Positive, "=" => Types.Eq); (Vecs.Vector objects will grow as needed.) Another option is to instantiate a "definite" container generic with a pointer type, which is definite. Its access values will point to any object in some hierarchy. (This can mean pointers to any objects that share the same interface (Ada 2005 keyword), so types need not even be rooted at the same one parent type, I think). For example package S_Lists is new Ada.Containers.Doubly_Linked_Lists (Element_Type => Some_Hier_Ptr, "=" => ...); Georg