[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Need explanation on Symbol table

Posted on 2007-03-29
5
Medium Priority
?
728 Views
Last Modified: 2012-06-27
Hi experts,

      Can anybody explain me the concept on symbol tables in detail with a small c program example?
I need the explation to address the following questions:
+ Why it is needed ? what is the use of it?

I know  I may be asking a silly question , but I need  an excellet answers from the experts.


Thanks

0
Comment
Question by:expertblr
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 51

Accepted Solution

by:
Steve Bink earned 2000 total points
ID: 18819280
Symbol tables have no real simple explanation.  

Say you're building a program.  Inside that program, you are assigning variables like 'x' or 'y'.  When you create the variable, the computer sets aside a section of memory for it (in the stack or heap...more terms!  yay!).  The amount of space reserved depends on the variable.  For example, a single character takes up one byte, integers take 4 (or more) bytes, etc.  The amount of space is OS-dependent as well; different systems use different data types.

So now you have variables 'x' and 'y'.  But the computer does not understand x or y...it understands 1's and 0's.  At this point, the computer knows what you're calling it, and it knows where it is holding the value.  It creates a table in memory to match the two - the symbol table.  Now every time you look up 'x', the computer goes to the symbol table and finds the address it gave to that variable, then goes to that address and returns the value you stored.  

Symbol tables are necessary as part of the translation from our language to the computer's.  As mentioned earlier, these are very OS-dependent and can vary widely in format, usage, and purpose.  In a compiler, the symbol table is created as a manifest for all declared variables.  As the compiler executes passes over the code it is compiling, it replaces plain-language variable references with the segment:offset pair for that variable's address.  In PHP, the symbol table is the global scope...just a place to hold variables.

I hope this explains well enough.  I have not dealt directly with symbol tables since assembler in 1984 or something, and I'm sure they have evolved tremendously over the years.
0
 
LVL 14

Expert Comment

by:kenfcamp
ID: 18819296
[I need the explation to address the following questions:
  Why it is needed ?
   what is the use of it?]


Sounds more like a home work assignment to me
0
 
LVL 51

Expert Comment

by:Steve Bink
ID: 18819567
That it does, but I didn't need any code so....  :)  Understanding concept is what homework is all about.
0
 
LVL 84

Expert Comment

by:ozo
ID: 18820486
#include <stdio.h>
main(){
  int i=1;
  printf("%d\n",i);
}
the compiler need to know that the first i refers to the same variable as the second i
it also needs to know what printf is.
To keep track of these things, it uses a symbol table
0
 

Author Comment

by:expertblr
ID: 18882553
Thanks routinet.  I appricate  your help  without listening to others for whom it may look as an homework assignment.  Full pioints to you routinet.
0

Featured Post

 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Over the last ten+ years I have seen Linux configuration tools come and go. In the early days there was the tried-and-true, all-powerful linuxconf that many thought would remain the one and only Linux configuration tool until the end of times. Well,…
Using 'screen' for session sharing, The Simple Edition Step 1: user starts session with command: screen Step 2: other user (logged in with same user account) connects with command: screen -x Done. Both users are connected to the same CLI sessio…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Suggested Courses
Course of the Month14 days, 11 hours left to enroll

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question