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.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no 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,UTF8 Path: g2news1.google.com!news3.google.com!feeder.news-service.com!85.214.198.2.MISMATCH!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail From: Natasha Kerensikova Newsgroups: comp.lang.ada Subject: Re: S-expression I/O in Ada Date: Sun, 22 Aug 2010 10:43:02 +0000 (UTC) Organization: A noiseless patient Spider Message-ID: References: <547afa6b-731e-475f-a7f2-eaefefb25861@k8g2000prh.googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Date: Sun, 22 Aug 2010 10:43:02 +0000 (UTC) Injection-Info: mx01.eternal-september.org; posting-host="Mda950WjNwNLAFOE7yJXQw"; logging-data="14284"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+agdR3gUkUUhwLTCO2b6wx" User-Agent: slrn/0.9.9p1 (FreeBSD) Cancel-Lock: sha1:aZyxOEssDrqTOOvqsZF8HZhqzRg= Xref: g2news1.google.com comp.lang.ada:13602 Date: 2010-08-22T10:43:02+00:00 List-Id: On 2010-08-19, Jeffrey Carter wrote: >> And if there is no other way, would it make sense to get rid of the >> discriminant with something like: >> >> type S_Expression is tagged null record; >> >> package Lists is new Ada.Containers.Indefinite_Doubly_Linked_List >> (Element_Type => S_Expression'Class); >> >> type Atom_Node is new S_Expression with record >> Value : Atom; >> end record; >> >> type List_Node is new S_Expression with record >> List : Lists.Vector; >> end record; > > This sort of approach would work, though I don't much like it. There's > no representation of a complete S-expression, just for the bits one is > made up of. Well technically, any S-expression node is also a full-fledged S-expression. A subprogram taking any kind of node would look like: procedure Make_Bar (From : S_Expression'Class); > explicit discriminant is generally clearer. Thinking about it, I start believing you're right. > You could also make the explicit discriminant visible, eliminating the > Is_Atom function, and declaring subtypes, which would eliminate the > need for the explicit exceptions and tests. That might be a good idea. Actually I find an enumerated discriminant clearer than a boolean one, at least for that particular case. However I'm still unsure about the pros and cons for having a public discriminant rather than a private one. >> Natacha > > So which is it, Natasha or Natacha? They are both transliterations of Наташа, the former being English while the latter is French. In an English context I consider both of them equally valid, the first has a better integration in the English flow while the latter is what is actually written on my ID. Do I really have to pick one? Thanks for your help, Natasha