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,ASCII-7-bit Path: g2news1.google.com!news1.google.com!goblin1!goblin.stu.neva.ru!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: Thu, 19 Aug 2010 10:16:00 +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=us-ascii Content-Transfer-Encoding: 7bit Injection-Date: Thu, 19 Aug 2010 10:16:00 +0000 (UTC) Injection-Info: mx01.eternal-september.org; posting-host="Mda950WjNwNLAFOE7yJXQw"; logging-data="4688"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/PLspg7iyHU9F+4T91VDeF" User-Agent: slrn/0.9.9p1 (FreeBSD) Cancel-Lock: sha1:mLFx1QDAemnJSeMvbLqmI3l/PTI= Xref: g2news1.google.com comp.lang.ada:13511 Date: 2010-08-19T10:16:00+00:00 List-Id: On 2010-08-19, Natasha Kerensikova wrote: > On 2010-08-18, Jeffrey Carter wrote: >> Yes, ideally we want a list of S_Expression. However, the language >> doesn't allow us to create that directly. I can't instantiate Vectors >> with S_Expression before I declare S_Expression, and I can't declare >> S_Expression until I've instantiated Vectors for lists. > > OK, I understand the catch-22 problem here. I guess it will be the same > with linked lists instead of vectors. > > Is there any other (perhaps more difficult for a beginner) way to > address that issue? 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; There definitions would of course be private, though I guess S_Expression, Atom_Node, List_Node and their lineage would be public. That would allow subprogram to explicit whether they work on/return atoms, lists, or any kind of S_Expression. Does it make sense? Is it better or worse or just different? Would conversion from *_Node to S_Expression be to difficult or too heavy to make this realistic? Thanks for your help, Natacha