How is a symbol table represented in method overloading?
Asked
Active
Viewed 304 times
-5
-
Can you add more detail around this question? Does this question make sense if we use an other type? For now i read it as "How is type T represented in method overloading?" and the answer is "Yes like any overload method have the same name but other parameter like `class Test { static void Foo(int x) { Console.WriteLine("Foo(int x)"); } static void Foo(string y) { Console.WriteLine("Foo(string y)"); }`" – xdtTransform Feb 01 '19 at 09:37
1 Answers
2
The compilers that I am familiar with do it by synthesizing a unique name for each overload based on the given name and the types of the arguments.
Say for example you have three overloads for a function, MyFunc:
void MyFunc(int arg1);
void MyFunc(double arg1);
void MyFunc(int arg1, int arg2);
Internally, the compiler might call them
MyFunc$i4
MyFunc$d8
MyFunc$i4$i4
or similar, where the $
delimiter here is some character that isn't allowed in user-defined symbol names, and the suffixes are made up of short-hand code symbols for basic data types (i4 = 4-byte signed integer, d8 = double, and so on).
(The scheme I show here is just something I made up to illustrate the principle. To see how it's actually done, google compiler name mangling
).

500 - Internal Server Error
- 28,327
- 8
- 59
- 66