Re: How is the concept of scope implemented?

"Tony" <tony@my.net>
Wed, 19 Nov 2008 23:34:07 -0600

          From comp.compilers

Related articles
[9 earlier articles]
Re: How is the concept of scope implemented? kamalpr@hp.com (kamal) (2008-11-18)
Re: How is the concept of scope implemented? DrDiettrich1@aol.com (Hans-Peter Diettrich) (2008-11-19)
Re: How is the concept of scope implemented? yangjunpro@gmail.com (yangjunpro: Target locked-->Ruby++) (2008-11-18)
Re: How is the concept of scope implemented? j.vimal@gmail.com (Vimal) (2008-11-19)
Re: How is the concept of scope implemented? tony@my.net (Tony) (2008-11-19)
Re: How is the concept of scope implemented? tony@my.net (Tony) (2008-11-19)
Re: How is the concept of scope implemented? tony@my.net (Tony) (2008-11-19)
Re: How is the concept of scope implemented? lkrupp@pssw.com (Louis Krupp) (2008-11-21)
| List of all articles for this month |

From: "Tony" <tony@my.net>
Newsgroups: comp.compilers
Date: Wed, 19 Nov 2008 23:34:07 -0600
Organization: at&t http://my.att.net/
References: 08-11-054 08-11-094
Keywords: storage, symbols
Posted-Date: 20 Nov 2008 17:47:44 EST

"kamal" <kamalpr@hp.com> wrote in message news:08-11-094@comp.compilers...
> On Nov 14, 12:40 pm, "Tony" <t...@my.net> wrote:
>> In C++, there is many kinds of scope: global, translation unit, function,
>> local (between the curly brackets within a function), class and probably
>> more. How is the concept of scope implemented by a compiler for a
>> program?
>>
>> Tony
>
> For static variables.
> The same way as for C -a tree of stacks. The scope in which you are
> executing shows the node where you are present in the tree, If a
> symbol is not found within a node, you look above (in the enclosing
> scope) till you hit the root node.


I can relate to trees (I've implemented a b+-tree for what I hope will
become my in-house embedded database). I think the biggest unknowns to me at
this time are those chasms between parsing and code generation.


>
> For member functions/variables,
> there is something called RTTI (run-time type identification) where
> the C++ runtime library resolves scope at runtime and enables you to
> call the appropriate member function. The instance of class which is
> used to call a member function is represented by an implicit pointer
> (this) and that is used to access variables when a member function
> accesses them.


Separate topic stuff. I've been "round-n-round" with the language guys about
that kind of stuff: RTTI, exceptions, templates. Currently, I AVOID using
those things in C++ because I don't know how they are implemented and I may
want to exclude those things from "my language" (and find a better solution
perhaps or just do without) if they are "too messy". (Again, separate
topic).


That said, the question becomes: Is RTTI THE (uppercase) solution to the
problem? Is the "problem" polymorphism? If that IS the problem that RTTI
solves: I AM ALL EARS!!! (Because I have BIG issues with vptrs).


Tony



Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.