Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Beginner question: What is binding?

I was trying to understand the difference between early and late binding, and in the process realized that the concept of binding is nebulous to me. I think I understand that it relates to the way data-as-a-word-of-memory is linked to type-as-a-set-of-language-features but I am not sure those are the right concepts. Also, how does understanding this deeply help people become better programmers?

Please note: This question is not "what is late v. early binding" or "what are the trade-offs between the 2". Those already exist here.

Thanks,

JDelage

like image 240
JDelage Avatar asked Apr 23 '10 13:04

JDelage


1 Answers

At its simplest, binding is the association of a symbol within a program with an address in memory.

For example: a function call in C. When you declare a function, the compiler records the function's name and the location of its code within the object file. When you call a function from a separately compiled file, the compiler records a reference to that name in the place where the call occurs. The linker is responsible for binding these two references, so that the call will reference the correct memory location.

like image 141
Anon Avatar answered Oct 23 '22 18:10

Anon