comp.lang.ada
 help / color / mirror / Atom feed
From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: Interesting containers problem.
Date: Mon, 20 Apr 2015 18:39:54 -0500
Date: 2015-04-20T18:39:54-05:00	[thread overview]
Message-ID: <mh42ob$5kp$1@loke.gir.dk> (raw)
In-Reply-To: ced95bb5-0bb3-43ee-8d2c-212ea020fd10@googlegroups.com

"Shark8" <onewingedshark@gmail.com> wrote in message 
news:ced95bb5-0bb3-43ee-8d2c-212ea020fd10@googlegroups.com...
> On Friday, April 17, 2015 at 2:45:07 PM UTC-6, Randy Brukardt wrote:
...
> 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 keys are into a map of which each element is a list of tree nodes (that 
is, tree cursors) that have the given identifier. Thus, you have:

    package Symbol_Tree is new Ada.Containers.Indefinite_Multiway_Trees 
(Element_Type => Symbol_Root'Class);

    package Symbol_List is new Ada.Containers.Doubly_Linked_Lists 
(Element_Type => Symbol_Tree.Cursor);

    package Identifier_Map is new Ada.Containers.Indefinite_Hashed_Map 
(Element_Type => Symbol_List.List,
         Key_Type => String, -- Probably really a UTF8_String,
         Hash => ..., Equivalent_Keys => ...);

  I'm too lazy to look up the proper names of the routines to use for the 
Hash function and the case insensitive equivalency; it's not relevant to the 
routine anyway.

> 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.

But that doesn't help much (for Ada). In any case, you start with the entire 
list of declarations with the appropriate identifier and prune out 
inappropriate kinds of declarations (wrong scope, etc.). The problem is that 
declarations such as overloaded subprograms don't hide each other unless 
they're homographs (that is, have the same profile). The identifier alone 
doesn't tell you much; you have to collect all of the declarations that 
might be visible.

What you are talking about would help in an antique language that doesn't 
support any overloading, but I would hope that people in this group are 
beyond that. :-) If anything, Ada doesn't have enough overloading (too much 
reliance on scopes, something that should have almost no bearing on 
visibility).

Keep in mind that there are many possible queries into a symboltable, and 
it's never going to be viable to make it easy for all of them. For Ada, you 
need to look up by identifier, by visibility, by primitive for a given type, 
and so on. It's not sensible to make it easy to do all of those things.

                                                          Randy.







  parent reply	other threads:[~2015-04-20 23:39 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-17 13:42 Interesting containers problem Shark8
2015-04-17 19:12 ` Peter Chapin
2015-04-17 20:45   ` Randy Brukardt
2015-04-17 21:06     ` Dmitry A. Kazakov
2015-04-18 17:21     ` Shark8
2015-04-19 17:10       ` brbarkstrom
2015-04-20 23:39       ` Randy Brukardt [this message]
2015-04-21  3:05         ` Randy Brukardt
2015-04-21  8:06         ` Dmitry A. Kazakov
2015-04-21  8:28           ` J-P. Rosen
2015-04-21  8:45             ` Dmitry A. Kazakov
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox