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,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.140.202.13 with SMTP id x13mr11892987qha.8.1429377718856; Sat, 18 Apr 2015 10:21:58 -0700 (PDT) X-Received: by 10.182.20.212 with SMTP id p20mr66995obe.11.1429377718823; Sat, 18 Apr 2015 10:21:58 -0700 (PDT) Path: border1.nntp.dca1.giganews.com!nntp.giganews.com!j5no2474036qga.1!news-out.google.com!db6ni19183igc.0!nntp.google.com!l13no6877633iga.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Sat, 18 Apr 2015 10:21:58 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=75.161.70.239; posting-account=lJ3JNwoAAAAQfH3VV9vttJLkThaxtTfC NNTP-Posting-Host: 75.161.70.239 References: <8def4a86-5835-4368-b414-63e12f1074e8@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: Interesting containers problem. From: Shark8 Injection-Date: Sat, 18 Apr 2015 17:21:58 +0000 Content-Type: text/plain; charset=ISO-8859-1 Xref: number.nntp.giganews.com comp.lang.ada:192852 Date: 2015-04-18T10:21:58-07:00 List-Id: On Friday, April 17, 2015 at 2:45:07 PM UTC-6, Randy Brukardt wrote: > "Peter Chapin" wrote in message > > On Fri, 17 Apr 2015, Shark8 wrote: > > > >> Ok, so let's say we have a type for Identifiers: > > > > [snip] > > > >> And that's all well and good; however, there is one limitation here that > >> is revealed when you need nesting scopes -- there is, apparently, no way > >> to define an Element_Type to feed to Indefinite_Ordered_Maps which is an > >> instance of Indefinite_Ordered_Maps.Maps or an instance of Variable_Data > >> (by way of a variant record; even one which is forward declared). > >> > >> What would be the proper way to handle this sort of situation? > > > > Perhaps using access types directly? What if the Element_Type of the Map > > is an access type that points at an incomplete type, where the completion > > follows the instantiation of the Maps generic? > > Bleech. Using access types means that you have to handle the memory > management, defeating the #1 value of the containers. Typically, you can use > cursors as references between related containers, and I think that is > preferable. > > To answer the OPs question, a symbol table for a language like Ada is a > multiway tree. That's one reason I pushed for a multiway tree container in > Ada, as it seems to be a common data structure. So I'd use a multiway tree > as the basic structure. Identifier lookups would use a map (as you noted), > and the things that each identifier points at is a list of the symbol table > nodes associated with that identifier. So the lookup data is a map of lists > of tree cursors. Hiding then is dealt with by checking the relationship of > the nodes, or possibly by maintaining a visibility flag in the symbol > records. Ok, I see how a multiway tree maps the structure of nesting scopes... but maybe I'm being obtuse here, because I don't see how to access them because there's no 'key' type. (Maybe a bit of code would help here.) The way I see it is that the structure we want is essentially a map where an identifier is keyed to one of two things: (a) a variable_data, or (b) another scope-map. -- This would allow/model nesting.