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.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC 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!news3.google.com!feeder2.cambriumusenet.nl!feeder3.cambriumusenet.nl!feed.tweaknews.nl!193.201.147.84.MISMATCH!xlned.com!feeder1.xlned.com!news.netcologne.de!newsfeed-fusi2.netcologne.de!newsfeed.straub-nv.de!uucp.gnuu.de!newsfeed.arcor.de!newsspool3.arcor-online.net!news.arcor.de.POSTED!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: S-expression I/O in Ada Newsgroups: comp.lang.ada User-Agent: 40tude_Dialog/2.0.15.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Reply-To: mailbox@dmitry-kazakov.de Organization: cbb software GmbH References: <547afa6b-731e-475f-a7f2-eaefefb25861@k8g2000prh.googlegroups.com> Date: Thu, 19 Aug 2010 12:42:21 +0200 Message-ID: <1llx0f5m88xj7$.srf8azjmykl0.dlg@40tude.net> NNTP-Posting-Date: 19 Aug 2010 12:42:18 CEST NNTP-Posting-Host: fe24b399.newsspool4.arcor-online.net X-Trace: DXC=VGFjGlTHVAQ[7Non7UCi8U4IUK On Thu, 19 Aug 2010 10:16:00 +0000 (UTC), Natasha Kerensikova wrote: > 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; The type tag in S_Expression'Class is a kind of discriminant. You replaced one with another. There could be other solutions how to build graphs, but in any case you need a common type or a set of types (=class) for all nodes of the graph. > Does it make sense? Yes. > Is it better or worse or just different? It is open ended. When using a discrete type for a discriminant you need to know all types of the nodes in advance. Using a type tag instead you can add new types of nodes later. It is a less fragile design in the end. > Would > conversion from *_Node to S_Expression be to difficult or too heavy to > make this realistic? For graphs, node is also a graph rooted in it. So you would need no conversion. When dealing with doubly-linked lists you inherit their referential semantics. It means that the node can be only in one list, though there might be many references to it. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de