Re: How is the concept of scope implemented?

Hans-Peter Diettrich <DrDiettrich1@aol.com>
Wed, 19 Nov 2008 04:57:01 +0100

          From comp.compilers

Related articles
[4 earlier articles]
Re: How is the concept of scope implemented? liangkun1983@gmail.com (Alex L.K) (2008-11-15)
Re: How is the concept of scope implemented? lkrupp@pssw.com (Louis Krupp) (2008-11-15)
Re: How is the concept of scope implemented? tony@my.net (Tony) (2008-11-18)
Re: How is the concept of scope implemented? tony@my.net (Tony) (2008-11-18)
Re: How is the concept of scope implemented? tony@my.net (Tony) (2008-11-18)
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: Hans-Peter Diettrich <DrDiettrich1@aol.com>
Newsgroups: comp.compilers
Date: Wed, 19 Nov 2008 04:57:01 +0100
Organization: Compilers Central
References: 08-11-054 08-11-062 08-11-089
Keywords: symbols, storage
Posted-Date: 19 Nov 2008 19:51:44 EST

Tony schrieb:


> 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:
[...]
> Compiler generates :
>
> void my_func()
> {
> EnterScope(my_func); // compiler generates
>
> // func code
>
> LeaveScope(my_func); // compiler generates
> }


I can't see anything inefficient here. When a scope requires allocation
of memory, on the stack or somewhere else, it doesn't matter whether
that memory is allocated and released by the coder or by the compiler.
In C++, Delphi etc. the compiler inserts the construction and
destruction of local objects, at the begin and end of every scope block.


Perhaps you missed that the scopes (as symbol tables) are required only
during compilation, not at runtime. Typical object files only contain
one symbol table, for use by the linker. More detailed debug information
may be created, too, but only for use by an interpreter or debugger.


DoDi


Post a followup to this message

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