From: | "Tony" <tony@my.net> |
Newsgroups: | comp.compilers |
Date: | Tue, 18 Nov 2008 15:59:13 -0600 |
Organization: | at&t http://my.att.net/ |
References: | 08-11-054 08-11-062 |
Keywords: | C++, symbols |
Posted-Date: | 18 Nov 2008 19:19:13 EST |
"Louis Krupp" <lkrupp@pssw.com> wrote in message
> Tony 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?
>
> The last time I looked at a (Burroughs Extended) ALGOL compiler, it used
> a linked list of symbol tables. When it entered a scope, it linked its
> symbol table to the head of the list; when it left a scope, it removed
> its table and pointed the list head at the previous scope.
I like the multiple table method, or some kind of
hierarchial/multi-data-structure thing. It seems to me though that
keeping track of the current scope can be a potential source of
inefficiency. For example:
Developer writes:
void my_func()
{
// func code
}
Compiler generates :
void my_func()
{
EnterScope(my_func); // compiler generates
// func code
LeaveScope(my_func); // compiler generates
}
Tony
Return to the
comp.compilers page.
Search the
comp.compilers archives again.