From: Daniel Jacobowitz <drow@mvista.com>
To: Jim Blandy <jimb@redhat.com>
Cc: gdb@sources.redhat.com
Subject: Re: C++ nested classes, namespaces, structs, and compound statements
Date: Tue, 09 Apr 2002 20:56:00 -0000 [thread overview]
Message-ID: <20020409235607.A23587@nevyn.them.org> (raw)
In-Reply-To: <npy9fwibd3.fsf@zwingli.cygnus.com>
I'm going to answer out-of-order a little bit, so pardon the
cut-n-paste butchery.
> I feel like we're planning a construction project like Boston's Big
> Dig or something: everything's got to keep running while we do the
> work, and things will get pretty ugly in there for a while, but we
> hope (if our funding doesn't run out) that in the end it'll all be
> beautiful.
>
As much of a pain as they are, I recommend a CVS branch for this. Then
we can see how it comes together with some history and a little less
destabilization. We still need to know where we're going first, of
course.
On Tue, Apr 09, 2002 at 08:35:52PM -0500, Jim Blandy wrote:
>
> Ah, this is exactly the kind of debate I was looking for. :)
>
> Daniel Jacobowitz <drow@mvista.com> writes:
> > But let me put my cynic's cap on for a moment and point out some
> > problems. I'd love to see us just decide to overcome them all, and I
> > think it's viable, but we need to make sure we consider them first.
> >
> > The "incremental change" Problem
>
> This I especially suck at. So folks, please insist on getting an
> answer you're really comfortable with.
>
> Here's one way we could approach it:
>
> - First, we could simply replace the `nsyms' and `syms' members of
> `struct block' with a reference to our opaque `environment' object.
> There isn't that much code which works on those directly, so this
> wouldn't be too bad.
And most of it will be very easy to find, because I went through all of
it quite recently. Remember my tries last October or so to change syms
from a list to a hash table? I've still got all that code, and while
none of it went in, at least I cleaned up every access to those members
I can find. Everything that iterates over them (with perhaps one
exception in the COFF code, IIRC) uses ALL_BLOCK_SYMBOLS. All accesses
go through the proper macros.
> - Next, we could replace the static and global blocks with `environment'
> objects, too.
>
> At this point, our environment object would be known to work. *ahem*
>
> - Make accessing a symbol's name go through an accessor function. It
> goes through a macro already, but we'd have to make sure it *always*
> goes through the macro. (Renaming the structure member and tweaking
> the macro accordingly would help us find code which doesn't go
> through the macro.)
>
> - Then we could go through an intermediate phase where things worked
> like this:
>
> a) The symbol table stores names either way: with an explicit
> namespace tree, or with qualified names sitting directly in the
> symbol table. (When I say "namespace", please understand that to
> also include classes, etc.) Any given symbol is stored only one
> way or the other, but any given symbol table can hold a mix of
> symbols in each form. Symbols stored in the explicit tree would
> have a `fully_qualified_name' field, so symtab clients expecting
> to see fully qualified names would still get them.
OK so far... we might want to take the path of least resistence, leave
the name fully qualified, and add an unqualified_name.
> b) The object representing a namespace keeps around the prefix it
> corresponds to (`std::' or `A::B::' or whatever), so that lookups of
> single name components relative to that namespace can find entries
> stored in either form.
>
> c) For backwards compatibility, the symbol lookup function would check
> for `::' in symbol names, and do a component-by-component lookup.
We might also want to check for '.', as per Java (in existing gcj
versions, at least).
> Then, we could gradually do the following (some of these are
> interdependent, some not):
>
> - Change symbol table clients to call a function to print a symbol's
> qualified name relative to the current scope, rather than expecting
> to see a fully qualified name in the symbol structure itself. This
> would make b) unnecessary.
>
> - Change symbol table clients to do lookups one component at a time,
> making c) unnecessary.
>
> - Change symbol table readers to build explicit namespace trees,
> rather than dumping qualified names into the symbol table. This
> would make a) unnecessary.
>
> Now we've got symbol lookups switched over. Given the new
> representation, we can implement namespaces in a straightforward way.
>
> But what about structs? I don't have enough of a grasp on how data
> members, member functions, static members, etc. really work now to say
> how we'd switch struct types over to the new representation, but it
> seems like the same general approach should work:
>
> - Gradually replace code which manipulates the type structures
> directly with simple accessor functions, until the type can be made
> opaque.
They mostly are, already.
> - Switch to an intermediate representation which allows both the old
> and the new representations, mixed.
Not for a given type, certainly. So not quite the same as with
symbols; a type would be one or the other.
> - Migrate clients and producers over to the newer interfaces. This is
> now a set of independent changes, that can be done in any order.
>
> - Once the producers are all creating data in the new style, remove
> support for it. Now you've got your new data structure, used as an
> opaque datatype.
And hopefully we'd reach this step, rather than being left with the
mess in the middle.
I like it. Who wants to start? :) We probably want to start with
interfaces, and then see where we need to go from there.
--
Daniel Jacobowitz Carnegie Mellon University
MontaVista Software Debian GNU/Linux Developer
next prev parent reply other threads:[~2002-04-10 3:56 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-04-05 20:42 Jim Blandy
2002-04-05 22:05 ` Daniel Berlin
2002-04-05 22:34 ` Daniel Jacobowitz
2002-04-05 23:49 ` Daniel Berlin
2002-04-06 7:18 ` Dan Kegel
2002-04-06 9:26 ` Gianni Mariani
2002-04-06 11:57 ` Daniel Berlin
2002-04-08 17:24 ` Jim Blandy
2002-04-08 17:03 ` Jim Blandy
2002-04-08 18:59 ` Daniel Jacobowitz
2002-04-09 18:35 ` Jim Blandy
2002-04-09 20:56 ` Daniel Jacobowitz [this message]
2002-04-12 15:08 ` Jim Blandy
2002-04-12 16:32 ` Daniel Jacobowitz
2002-04-08 17:19 ` Jim Blandy
2002-04-08 18:49 ` Daniel Jacobowitz
2002-04-10 10:31 ` Jim Blandy
2002-04-10 12:08 ` Daniel Jacobowitz
2002-04-12 13:58 ` Jim Blandy
2002-04-12 16:56 ` Daniel Jacobowitz
2002-04-16 12:08 ` Jim Blandy
2002-04-16 14:01 ` Daniel Jacobowitz
2002-04-16 14:52 ` Jim Blandy
2002-04-16 14:58 ` Daniel Jacobowitz
2002-04-06 6:31 ` Andrew Cagney
2002-04-06 7:58 ` Daniel Berlin
2002-04-08 0:59 ` Joel Brobecker
2002-04-08 2:01 ` Doubt in GDB SathisKanna k
2002-04-06 8:49 ` C++ nested classes, namespaces, structs, and compound statements Per Bothner
2002-04-08 16:29 ` Jim Blandy
2002-04-08 16:48 ` Daniel Jacobowitz
2002-04-09 6:55 ` Petr Sorfa
2002-04-10 10:34 ` Jim Blandy
2002-04-10 12:31 ` Daniel Berlin
2002-04-10 12:53 ` Petr Sorfa
2002-04-05 22:02 Michael Elizabeth Chastain
2002-04-05 22:13 ` Daniel Berlin
2002-04-05 22:30 ` Daniel Berlin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20020409235607.A23587@nevyn.them.org \
--to=drow@mvista.com \
--cc=gdb@sources.redhat.com \
--cc=jimb@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox