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!news3.google.com!feeder.news-service.com!news.netcologne.de!newsfeed-hp3.netcologne.de!nf02.dk.telia.net!starscream.dk.telia.net!news.tele.dk!news.tele.dk!small.news.tele.dk!bnewspeer01.bru.ops.eu.uu.net!bnewspeer00.bru.ops.eu.uu.net!emea.uu.net!newsfeed.arcor.de!newsspool2.arcor-online.net!news.arcor.de.POSTED!not-for-mail Date: Wed, 18 Aug 2010 13:22:01 +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> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Message-ID: <4c6bc259$0$6887$9b4e6d93@newsspool2.arcor-online.net> Organization: Arcor NNTP-Posting-Date: 18 Aug 2010 13:22:01 CEST NNTP-Posting-Host: ec48220c.newsspool2.arcor-online.net X-Trace: DXC=B[JJ=W`C2]C^B]`=U:WelBA9EHlD;3YcB4Fo<]lROoRA8kFJLh>_cHTX3jMOl^1Rmbl09C X-Complaints-To: usenet-abuse@arcor.de Xref: g2news1.google.com comp.lang.ada:13478 Date: 2010-08-18T13:22:01+02:00 List-Id: On 18.08.10 12:49, Natasha Kerensikova wrote: >> type S_Expression (Is_Atom : Boolean) is new Root with record >> case Is_Atom is >> when False => >> List : Lists.Vector; >> when True => >> Value : Atom; >> end case; >> end record; > > I don't understand why you need Indefinite_Vectors here. They have been > presented to me as heterogeneous vector containers, but here Lists would > be homogeneous, containing only S_Expression items. > I'm not sure about the need of Root either, but my guess is that it's to > provide a common root to all objects contained in the > Indefinite_Vectors. > > But what makes S_Expression an indefinite type? The type S_Expression is not constrained: Is_Atom has no fixed value. It is an unknown discriminant. (LRM 3.3 says---in order to give a reason I guess---"An indefinite subtype does not by itself provide enough information to create an object".) An S_Expression object that has Is_Atom = True can have a layout different from that of an object with Is_Atom = False, and has different components. The objects are heterogeneous in this sense. (Imagine creating two subtypes: subtype SA is S_Expression (Is_Atom => True); subtype SL is S_Expression (Is_Atom => False); Then, A : SA; L : SL; will be objects that might or might not take up the same amount of storage, but more importantly, A has a Value component, L does not, it has a List component, perhaps unlike C unions, cast.) When instantiating a container generic without Indefinite_ in its name, a definite subtype is needed. Georg